Ejemplo n.º 1
0
        public static bool Invoke(MessageType messageType, IRpc rpc, IWriteStream writeStream, IPeer peer, ResponseCallback responseCallback)
        {
            if (peer == null)
            {
                Logger.Error($"{nameof(peer)} 为 null");
                return(false);
            }

            if (!_messages.TryGetValue(MessageType.RpcInvoke, out var func))
            {
                Logger.Error($"没有注册${nameof(RpcInvoke)}");
                return(false);
            }

            rpc.SerializeFields(writeStream);
            writeStream.ShiftLeft((short)messageType);
            return(peer.SendMessage(writeStream, responseCallback));
        }