private void HandleServerPushMessage(ITcpConnection connection, RemotingServerMessage message)
 {
     if (_remotingServerMessageHandlerDict.TryGetValue(message.Code, out IRemotingServerMessageHandler messageHandler))
     {
         messageHandler.HandleMessage(message);
     }
     else
     {
         _logger.ErrorFormat("No handler found for remoting server push message, name: {0}, message: {1}", Name, message);
     }
 }
Пример #2
0
        private static byte[] BuildRemotingServerMessage(RemotingResponse remotingResponse)
        {
            byte[] remotingResponseData  = RemotingUtil.BuildResponseMessage(remotingResponse);
            var    remotingServerMessage = new RemotingServerMessage(
                RemotingServerMessageType.RemotingResponse,
                100,
                remotingResponseData,
                null);

            return(RemotingUtil.BuildRemotingServerMessage(remotingServerMessage));
        }
Пример #3
0
        public static byte[] BuildRemotingServerMessage(RemotingServerMessage message)
        {
            byte[] IdBytes;
            byte[] IdLengthBytes;
            ByteUtil.EncodeString(message.Id, out IdLengthBytes, out IdBytes);

            var typeBytes         = BitConverter.GetBytes(message.Type);
            var codeBytes         = BitConverter.GetBytes(message.Code);
            var createdTimeBytes  = ByteUtil.EncodeDateTime(message.CreatedTime);
            var headerBytes       = HeaderUtil.EncodeHeader(message.Header);
            var headerLengthBytes = BitConverter.GetBytes(headerBytes.Length);

            return(ByteUtil.Combine(
                       IdLengthBytes,
                       IdBytes,
                       typeBytes,
                       codeBytes,
                       createdTimeBytes,
                       headerLengthBytes,
                       headerBytes,
                       message.Body));
        }
Пример #4
0
        public void PushMessageToAllConnections(RemotingServerMessage message)
        {
            var data = RemotingUtil.BuildRemotingServerMessage(message);

            ServerSocket.PushMessageToAllConnections(data);
        }