Initiate a request to the server failed: SendError

GrimGrim
edited January 10 in DotNet

My Client Code is:

 public override void Execute(int eventCode, object message)
    {
        switch (eventCode)
        {
            case 0:
                socketMsg = message as SocketMsg;
                Dictionary<byte,object> p = new Dictionary<byte,object>();
                p[0] = socketMsg.Value;
                OperationRequest((byte)socketMsg.OpCode, p, (byte)socketMsg.SubCode);
                Debug.Log("It's ok");
                break;
            default:
                break;
        }
    }

public void OperationRequest(byte opCode, Dictionary<byte,object> parameters = null, byte subCode = 0)
    {
        
        parameters[80] = subCode;
        peer.OpCustom(opCode, parameters, true);
    }

The Error detail:

SendError
UnityEngine.Debug:Log(Object)
PhotonManager:OnStatusChanged(StatusCode) (at Assets/Scripts/Net/PhotonManager.cs:144)
ExitGames.Client.Photon.EnetPeer:EnqueueOperation(Dictionary`2, Byte, Boolean, Byte, Boolean, EgMessageType)
ExitGames.Client.Photon.PeerBase:EnqueueOperation(Dictionary`2, Byte, Boolean, Byte, Boolean)
ExitGames.Client.Photon.PhotonPeer:OpCustom(Byte, Dictionary`2, Boolean, Byte)
ExitGames.Client.Photon.PhotonPeer:OpCustom(Byte, Dictionary`2, Boolean)
PhotonManager:OperationRequest(Byte, Dictionary`2, Byte) (at Assets/Scripts/Net/PhotonManager.cs:101)
PhotonManager:Execute(Int32, Object) (at Assets/Scripts/Net/PhotonManager.cs:84)
MsgCenter:Dispatch(Int32, Int32, Object) (at Assets/Scripts/Framework/Msg/MsgCenter.cs:50)
UIBase:Dispatch(Int32, Int32, Object) (at Assets/Scripts/UI/UIBase.cs:50)
LoginView:GetConfig() (at Assets/Scripts/UI/LoginView.cs:76)
LoginView:IsNetworkConnect() (at Assets/Scripts/UI/LoginView.cs:67)
LoginView:Start() (at Assets/Scripts/UI/LoginView.cs:46)

How should I solve it?

Best Answer

  • GrimGrim
    edited January 10 Accepted Answer
    My question has been resolved, the reason is the order in which the code is executed, before the connection is successful, the request is sent, so returned SendError. Now add the judgment condition, if connected, then send the request.

Answers

  • GrimGrim
    edited January 10 Accepted Answer
    My question has been resolved, the reason is the order in which the code is executed, before the connection is successful, the request is sent, so returned SendError. Now add the judgment condition, if connected, then send the request.
Sign In or Register to comment.