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);
     }
 }
Example #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));
        }
Example #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));
        }
Example #4
0
        public void PushMessageToAllConnections(RemotingServerMessage message)
        {
            var data = RemotingUtil.BuildRemotingServerMessage(message);

            ServerSocket.PushMessageToAllConnections(data);
        }