Exemplo n.º 1
0
        /// Internal used by _RPCRetHandler.
        public void _OnRPCTimeout(_RPCRetHandler rpcRetHandler)
        {
            bool ret = _rpcRetHandlers.Remove(rpcRetHandler._CallMessage._GetRPCID());

            if (!ret)
            {
                string msg = string.Format("RPC call {0} timeout, but it is not in the _rpcRetHandlerMap!", rpcRetHandler._CallMessage);
                Debugger.LogError(msg);
            }
        }
Exemplo n.º 2
0
 /// Internal used by _RPCRetHandler.
 public void _CancelRPCCall(_RPCRetHandler rpcRetHandler)
 {
     if (_rpcRetHandlers.Remove(rpcRetHandler._CallMessage._GetRPCID()))
     {
         rpcRetHandler._HandleRPCReturn(null, NetMessage.CANCELED);
         Debugger.LogWarning("RPC call " + rpcRetHandler._CallMessage + " was canceled!");
     }
     else
     {
         Debugger.LogWarning("RPC call " + rpcRetHandler._CallMessage + " canceling failed, the call already done!");
     }
 }
Exemplo n.º 3
0
        public _RPCRetHandler Call(NetRPCCall callMessage
                                   , Action <_NetRPCReturn, Exception> callback
                                   , long timeout)
        {
            __rpcIndex = 1 + ((__rpcIndex + 1) % 65534);
            callMessage._SetRPCID(__rpcIndex);

            _RPCRetHandler rpcRetHandler = new _RPCRetHandler(this, callMessage
                                                              , timeout, callback);

            _rpcRetHandlers.Add((ushort)__rpcIndex, rpcRetHandler);

            _connection.SendNetMessage(callMessage);

            return(rpcRetHandler);
        }
Exemplo n.º 4
0
        public void _OnRPCReturn(_NetRPCReturn rpcReturn)
        {
            Debugger.Assert(rpcReturn._GetRPCID() != 0);

            /// Call the callback.
            _RPCRetHandler rpcRetHandler = _rpcRetHandlers[rpcReturn._GetRPCID()];

            _rpcRetHandlers.Remove(rpcReturn._GetRPCID());

            if (rpcRetHandler != null)
            {
                rpcReturn.type = rpcRetHandler._CallMessage.type;
                rpcRetHandler._HandleRPCReturn(rpcReturn, null);
            }
            else
            {
                string msg = string.Format("Received a RPC response, but the RPC_ID {0} is invalid (not in _rpcCallMap). "
                                           + "The RPC call may be timeout or RPC response corrupted!"
                                           , rpcReturn._GetRPCID());
                Debugger.LogError(msg);
            }
        }