示例#1
0
    public void SendMsg(MessageBase msg)
    {
        short msgType = 0;

        if (msg.GetType().Name == "TextMessage")
        {
            msgType = MRTMsgType.Text;
        }
        else if (msg.GetType().Name == "AnchorMessage")
        {
            msgType = MRTMsgType.Anchor;
        }
        else if (msg.GetType().Name == "SpawnMessage")
        {
            msgType = MRTMsgType.Spawn;
        }

        NetworkWriter writer = new NetworkWriter();

        writer.StartMessage(msgType);

        msg.Serialize(writer);

        writer.FinishMessage();

        // send message to server
        stream.Write(writer.ToArray(), 0, writer.ToArray().Length);
    }
示例#2
0
 private Message GetMessage(MessageBase message)
 {
     return new Message
                {
                    Formatter = new XmlMessageFormatter(new[] {message.GetType()}),
                    Label = message.GetType().FullName,
                    Body = message
                };
 }
示例#3
0
        public void PublishTopic(MessageBase msg, string queueName, string borkerList)
        {
            if (!_producerConnection.IsConnected)
            {
                _producerConnection.TryConnect();
            }

            var eventName = msg.GetType()
                            .Name;
            Message <string, MessageBase> message = new Message <string, MessageBase>()
            {
                Key = eventName, Value = msg
            };

            var policy = RetryPolicy.Handle <KafkaException>()
                         .WaitAndRetry(5, retryAttempt => TimeSpan.FromSeconds(Math.Pow(2, retryAttempt)), (ex, time) =>
            {
                _logger.LogWarning(ex.ToString());
            });

            using (var conn = _producerConnection.CreateConnect() as IProducer <string, MessageBase>)
            {
                policy.Execute(() =>
                {
                    conn.ProduceAsync(eventName, message);
                });
            }
        }
    public override bool Send(short msgType, MessageBase msg)
    {
        Type messageType = msg.GetType();
        //Because of the problem with child spawning we intercept normal spawns and replace it with our own if we are under the correct conditions
        //This is highly illegal never do this
        if (messageType.Name == "ObjectSpawnMessage")
        {
            NetworkInstanceId networkId = (NetworkInstanceId) messageType.GetField("netId").GetValue(msg);

            GameObject foundObject = NetworkServer.FindLocalObject(networkId);
            if (foundObject == null)
                return base.Send(msgType, msg);

            ChildIdentity childId = foundObject.GetComponent<ChildIdentity>();
            if (childId == null)
                return base.Send(msgType, msg);

            byte[] payload = (byte[]) messageType.GetField("payload").GetValue(msg);

            //Intercept the message with a child message
            return base.Send(ChildSpawnMessage.MessageId, new ChildSpawnMessage(childId, payload));
        }

        return base.Send(msgType, msg);
    }
示例#5
0
        private void OnMessageReceived(MessageBase msg)
        {
            Type type = msg.GetType();

            if (type == typeof(ValidationRequest))
            {
                ValidationRequestHandler(msg as ValidationRequest);
            }
            else if (type == typeof(SessionRequest))
            {
                SessionRequestHandler(msg as SessionRequest);
            }
            else if (type == typeof(SessionResponse))
            {
                SessionResponseHandler(msg as SessionResponse);
            }
            else if (type == typeof(EndSessionRequest))
            {
                EndSessionRequestHandler(msg as EndSessionRequest);
            }
            else if (type == typeof(DisconnectRequest))
            {
                DisconnectRequestHandler(msg as DisconnectRequest);
            }
            else if (OtherSideReceiver != null)
            {
                OtherSideReceiver.SendMessage(msg);
            }
        }
示例#6
0
        public bool HandleNTLM(ref byte[] bytes)
        {
            var type = MessageBase.GetType(bytes);

            if (type < 0)
            {
                throw new InvalidOperationException();
            }

            if (type == 3)
            {
                // FIXME: We don't actually check the result.
                var message = new Type3Message(bytes);
                if (message.Type != 3)
                {
                    throw new InvalidOperationException();
                }

                return(true);
            }
            if (type == 1)
            {
                var message = new Type1Message(bytes);
                if (message.Type != 1)
                {
                    throw new InvalidOperationException();
                }

                var type2 = new Type2Message();
                bytes = type2.GetBytes();
                return(false);
            }

            throw new InvalidOperationException();
        }
        public static void SendMessageToPlayer(ulong steamId, MessageBase message)
        {
            Logger.Debug("SendMessageToPlayer {0} {1} {2}.", steamId, message.Side, message.GetType().Name);

            message.Side = MessageSide.ClientSide;
            byte[] byteData = MyAPIGateway.Utilities.SerializeToBinary(message);
            MyAPIGateway.Multiplayer.SendMessageTo(ConnectionId, byteData, steamId);
        }
示例#8
0
 public async Task Received(MessageBase @message)
 {
     await _amazonSqs.DeleteMessageAsync(new DeleteMessageRequest
     {
         QueueUrl      = _queueInfo.GetQueueUrl(@message.GetType()),
         ReceiptHandle = (string)@message.QueueData
     });
 }
示例#9
0
        private void OnMessageReceived(MessageBase msg)
        {
            var type = msg.GetType();

            if (msg is ResponseMessageBase)
            {
                if (type == typeof(GenericResponse))
                {
                    // ReSharper disable once PossibleNullReferenceException
                    msg = (msg as GenericResponse).ExtractInnerMessage();
                }

                // ReSharper disable once PossibleNullReferenceException
                InvokeMessageCallback(msg, (msg as ResponseMessageBase).DeleteCallbackAfterInvoke);

                if (type == typeof(RemoteDesktopResponse))
                {
                    RemoteDesktopResponseHandler(msg as RemoteDesktopResponse);
                }
                else if (type == typeof(FileUploadResponse))
                {
                    FileUploadResponseHandler(msg as FileUploadResponse);
                }
            }
            else
            {
                if (type == typeof(SessionRequest))
                {
                    SessionRequestHandler(msg as SessionRequest);
                }
                else if (type == typeof(EndSessionRequest))
                {
                    OnSessionEndedByTheRemoteClient();
                }
                else if (type == typeof(RemoteDesktopRequest))
                {
                    RemoteDesktopRequestHandler(msg as RemoteDesktopRequest);
                }
                else if (type == typeof(TextMessageRequest))
                {
                    TextMessageRequestHandler(msg as TextMessageRequest);
                }
                else if (type == typeof(FileUploadRequest))
                {
                    FileUploadRequestHandler(msg as FileUploadRequest);
                }
                else if (type == typeof(DisconnectRequest))
                {
                    OnSessionClientDisconnected();
                }
                else if (type == typeof(GenericRequest))
                {
                    OnGenericRequestReceived(msg as GenericRequest);
                }
            }
        }
示例#10
0
        public void Publish(MessageBase messageBase)
        {
            var invocationList = SubscriberCollection[messageBase.GetType()];

            foreach (var subscriber in invocationList)
            {
                var handler = subscriber.GetHandler();
                handler?.Invoke(subscriber.GetSubscriber(), new[] { messageBase });
            }
        }
示例#11
0
        protected virtual void OnMessageReceived(MessageBase msg)
        {
            Type type = msg.GetType();

            if (msg is ResponseMessageBase)
            {
                if (type == typeof(GenericResponse))
                {
                    msg = (msg as GenericResponse).ExtractInnerMessage();
                }

                InvokeMessageCallback(msg, (msg as ResponseMessageBase).DeleteCallbackAfterInvoke);

                if (type == typeof(RemoteDesktopResponse))
                {
                    RemoteDesktopResponseHandler(msg as RemoteDesktopResponse);
                }
                else if (type == typeof(FileUploadResponse))
                {
                    FileUploadResponseHandler(msg as FileUploadResponse);
                }
            }
            else
            {
                if (type == typeof(SessionRequest))
                {
                    SessionRequestHandler(msg as SessionRequest);
                }
                else if (type == typeof(EndSessionRequest))
                {
                    OnSessionEndedByTheRemoteClient();
                }
                else if (type == typeof(RemoteDesktopRequest))
                {
                    RemoteDesktopRequestHandler(msg as RemoteDesktopRequest);
                }
                else if (type == typeof(TextMessageRequest))
                {
                    TextMessageRequestHandler(msg as TextMessageRequest);
                }
                else if (type == typeof(FileUploadRequest))
                {
                    FileUploadRequestHandler(msg as FileUploadRequest);
                }
                else if (type == typeof(DisconnectRequest))
                {
                    OnSessionClientDisconnected();
                }
                else if (type == typeof(GenericRequest))
                {
                    OnGenericRequestReceived(msg as GenericRequest);
                }
            }
        }
示例#12
0
        private void SendCommand(MessageBase message)
        {
            var raw    = JsonSerializer.SerializeToUtf8Bytes(message, message.GetType());
            var output = new byte[raw.Length + 1];

            Array.Copy(raw, 0, output, 1, raw.Length);
            output[0] = message.OpCode;
            _client.SendAsync(output);
            AddLog("Sent " + output.Length + " bytes for OpCode " + message.OpCode);
            this._client.ReceiveAsync();
        }
示例#13
0
        public void Publish(MessageBase message)
        {
            var type = message.GetType();

            if (!_subscribers.ContainsKey(type))
            {
                return;
            }

            foreach (var subscription in _subscribers[type])
            {
                subscription.Invoke(message);
            }
        }
示例#14
0
        private void Serialize(MessageBase message, string xmlpath)
        {
            MemoryStream            StreamRequest = new MemoryStream();
            XmlSerializer           serializer    = new XmlSerializer(message.GetType());
            XmlSerializerNamespaces ns            = new XmlSerializerNamespaces();

            ns.Add(string.Empty, string.Empty);
            using (XmlWriter xmlWriter = XmlWriter.Create(StreamRequest))
            {
                xmlWriter.WriteDocType("message", null, message.DOCTYPE, null);
                serializer.Serialize(xmlWriter, message, ns);
                byte[] buffer = StreamRequest.GetBuffer();
                File.AppendAllText(xmlpath, UTF8Encoding.UTF8.GetString(buffer));
            }
        }
示例#15
0
        public static void Release(MessageBase msg)
        {
            var type = msg.GetType();

            if (!_messages.ContainsKey(type))
            {
                _messages[type] = new Stack <MessageBase>();
            }
            var list = _messages[type];

            if (list.Count >= _maxCount)
            {
                return;
            }
            list.Push(msg);
        }
示例#16
0
文件: TcpClient.cs 项目: Harquell/Eva
        public void SendMessage(MessageBase message)
        {
            try
            {
                using IDataWriter writer = new BigEndianWriter();
                message.Serialize(writer);
                byte[] buffer = writer.Data;
                _socket.BeginSend(buffer, 0, buffer.Length, SocketFlags.None, new AsyncCallback(SendMessageCallback), _socket);

                Logger.Debug(string.Format("Sending {0} message", message.GetType()));
            }
            catch (Exception e)
            {
                Logger.Error(e);
            }
        }
示例#17
0
        /// <summary>
        /// Checks whether the specified message is the one to intercept and processes it accordingly.
        /// </summary>
        /// <param name="message">The message to check for interception.</param>
        /// <returns><c>true</c> if the message was intercepted;<c>false</c> otherwise.</returns>
        public bool InterceptMessage(MessageBase message)
        {
            if (message == null)
            {
                return(false);
            }

            if ((message.Id == _messageID) && (message.GetType() == _messageType))
            {
                _message = message;
                _interceptionEvent.Set();
                return(true);
            }

            return(false);
        }
示例#18
0
        public async void SendMessage(MessageBase message)
        {
            Type type      = message.GetType();
            var  typeQuery = from attribute in type.GetCustomAttributes()
                             where attribute.GetType() == typeof(MessageTypeAttribute)
                             select attribute;

            if (typeQuery.Count() > 0)
            {
                string messageType     = (typeQuery as MessageTypeAttribute).Value;
                byte[] messageTypeData = Encoding.UTF8.GetBytes(messageType);
                await _Cctx.WriteAsync(BitConverter.GetBytes(messageTypeData.Length));

                await _Cctx.WriteAsync(messageTypeData);

                _Cctx.Flush();
            }
        }
示例#19
0
        public static void SendMessageTo(MessageBase message, ulong target)
        {
            if (!MyAPIGateway.Multiplayer.IsServer)
            {
                throw new Exception("Only server can send targeted messages");
            }

            if (_closing)
            {
                return;
            }

            message.Target     = target;
            message.TargetType = MessageTarget.Single;
            MyLog.Default.WriteLineAndConsole($"Sending message of type {message.GetType().FullName}");
            _outgoing.Enqueue(message);
            ReleaseLock();
        }
示例#20
0
        public static void SendMessageToPlayer(ulong steamId, MessageBase message)
        {
            Logger.Debug("SendMessageToPlayer {0} {1} {2}.", steamId, message.Side, message.GetType().Name);

            message.Side = MessageSide.ClientSide;
            var xml = MyAPIGateway.Utilities.SerializeToXML(new MessageContainer()
            {
                Content = message
            });

            byte[] byteData = System.Text.Encoding.Unicode.GetBytes(xml);
            if (byteData.Length <= MAX_MESSAGE_SIZE)
            {
                MyAPIGateway.Multiplayer.SendMessageTo(ConnectionId, byteData, steamId);
            }
            else
            {
                SendMessageParts(byteData, MessageSide.ClientSide, steamId);
            }
        }
        public async Task SendMessage(MessageBase message)
        {
            if (string.IsNullOrEmpty(_config.ServiceBusConnectionString))
            {
                throw new ArgumentException("No Service Bus Connection String is configured");
            }
            if (string.IsNullOrEmpty(_config.TopicName))
            {
                throw new ArgumentException("No Service Bus topic Name is configured");
            }

            var topicClient = new TopicClient(_config.ServiceBusConnectionString, _config.TopicName);
            var busMessage  = new Message(Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(message)))
            {
                Label         = message.GetType().Name, // we use label to route messages by body type
                ContentType   = "application/json",
                CorrelationId = message.CorrelationId
            };
            await topicClient.SendAsync(busMessage);

            await topicClient.CloseAsync();
        }
示例#22
0
        public void HandleMessage(byte[] message, TcpClient client)
        {
            using BigEndianReader reader = new BigEndianReader(message);
            ushort packetId = reader.ReadUShort();

            if (!_messageTypes.ContainsKey(packetId))
            {
                Logger.Error(string.Format("Received PacketId({0}) from {1} doesn't correspond to a message type", packetId, client.EndPoint));
                return;
            }
            if (!_messageHandlers.ContainsKey(packetId))
            {
                Logger.Error(string.Format("Received PacketId({0}) from {1} not handled", packetId, client.EndPoint));
                return;
            }
            MessageBase msg = Activator.CreateInstance(_messageTypes[packetId]) as MessageBase;

            msg.Deserialize(reader);

            Logger.Debug(string.Format("new packet data [{0}]{1}", packetId, msg.GetType().Name));

            _messageHandlers[packetId](msg, client.ClientData);
        }
示例#23
0
        private void OnMessageReceived(MessageBase msg)
        {
            Type type = msg.GetType();

            if (type == typeof(ValidationRequest))
            {
                ValidationRequestHandler(msg as ValidationRequest);
            }
            else if (type == typeof(SessionRequest))
            {
                SessionRequestHandler(msg as SessionRequest);
            }
            else if (type == typeof(SessionResponse))
            {
                SessionResponseHandler(msg as SessionResponse);
            }
            else if (type == typeof(EndSessionRequest))
            {
                EndSessionRequestHandler(msg as EndSessionRequest);
            }
            else if (type == typeof(DisconnectRequest))
            {
                DisconnectRequestHandler(msg as DisconnectRequest);
            }
            //else if (OtherSideReceiver != null)
            //{
            //    OtherSideReceiver.SendMessage(msg);
            //}
            else
            {
                foreach (var client in Server.Receivers.Where(x => x != this && x.Status != StatusEnum.Disconnected && x.ClientName == msg.ReceiverClient))
                {
                    msg.SenderClient = this.ClientName;
                    client.SendMessage(msg);
                }
            }
        }
示例#24
0
 public static void SendMessageToPlayer(ulong steamId, MessageBase message)
 {
     ConfigurableSpeedComponentLogic.Instance.ServerLogger.WriteVerbose("SendMessageToPlayer {0} {1} {2}.", steamId, message.Side, message.GetType().Name);
     message.Side = MessageSide.ClientSide;
     try
     {
         byte[] byteData = MyAPIGateway.Utilities.SerializeToBinary(message);
         MyAPIGateway.Multiplayer.SendMessageTo(SpeedConsts.ConnectionId, byteData, steamId);
     }
     catch (Exception ex)
     {
         ConfigurableSpeedComponentLogic.Instance.ServerLogger.WriteException(ex);
         ConfigurableSpeedComponentLogic.Instance.ClientLogger.WriteException(ex);
         //TODO: send exception detail to Server if on Client.
     }
 }
        /// <summary>
        /// The thread main of the message reading and processing thread.
        /// </summary>
        private void MessageReader()
        {
            try
            {
                object messageEnvelope = null;

                while ((messageEnvelope = _messageObjectStream.Read()) != null)
                {
                    MessageBase message = GetMessageFromEnvelope(messageEnvelope);

                    if (message == null)
                    {
                        this.Error("Received unexpected message envelope of type '{0}' -> ignore it.", messageEnvelope.GetType().Name);
                        continue;
                    }

                    if (message.GetType().Name == "KeepAliveRequest")
                    {
                        var response = new KeepAliveResponseEnvelope()
                        {
                            KeepAliveResponse = new KeepAliveResponse()
                            {
                                Id          = message.Id,
                                Source      = message.Destination,
                                Destination = message.Source
                            }
                        };

                        _messageObjectStream.Write(response);
                        continue;
                    }

                    lock (_activeInterceptors)
                    {
                        foreach (var interceptor in _activeInterceptors)
                        {
                            if (interceptor.InterceptMessage(message))
                            {
                                message = null;
                                break;
                            }
                        }
                    }

                    if ((message != null) && (this.MessageArrived != null))
                    {
                        this.Trace(
                            "MessageArrived event is raised: a new message arrived that is not handled by any pending message interceptors.");
                        this.MessageArrived(this, new MessageArrivedArgs()
                        {
                            Message = message
                        });
                    }
                }
            }
            catch (Exception ex)
            {
                this.Error("Reading and dispatching messages failed!", ex);
            }
            finally
            {
                lock (_activeInterceptors)
                {
                    foreach (var interceptor in _activeInterceptors)
                    {
                        interceptor.Cancel();
                    }
                }

                _threadDownEvent.Set();
            }

            try
            {
                if (this.MessageStreamDown != null)
                {
                    this.MessageStreamDown(this, null);
                }
            }
            catch (Exception ex)
            {
                this.Error("Throwing final message stream down event failed!", ex);
            }
        }
        public string GetPayload(MessageBase messageBase)
        {
            var wrapper = new ProtoMessageWrapper();

            switch (messageBase.MessageType)
            {
            case MessageType.SessionRequest:
            {
                var proto = SessionRequestMessageMapper.MapToProto((SessionRequestMessage)messageBase);
                wrapper.SessionRequestMessage = proto;

                break;
            }

            case MessageType.SessionReply:
            {
                var proto = SessionReplyMessageMapper.MapToProto((SessionReplyMessage)messageBase);
                wrapper.SessionReplyMessage = proto;

                break;
            }

            case MessageType.TransferRequest:
            {
                var proto = TransferRequestMessageMapper.MapToProto((TransferRequestMessage)messageBase);
                wrapper.TransferRequestMessage = proto;

                break;
            }

            case MessageType.TransferReply:
            {
                var proto = TransferReplyMessageMapper.MapToProto((TransferReplyMessage)messageBase);
                wrapper.TransferReplyMessage = proto;

                break;
            }

            case MessageType.TransferDispatch:
            {
                var proto = TransferDispatchMessageMapper.MapToProto((TransferDispatchMessage)messageBase);
                wrapper.TransferDispatchMessage = proto;

                break;
            }

            case MessageType.TransferConfirmation:
            {
                var proto = TransferConfirmationMessageMapper.MapToProto((TransferConfirmationMessage)messageBase);
                wrapper.TransaferConfirmationMessage = proto;

                break;
            }

            case MessageType.Termination:
            {
                var proto = TerminationMessageMapper.MapToProto((TerminationMessage)messageBase);
                wrapper.TerminationMessage = proto;

                break;
            }

            default:
                throw new ArgumentException($"Message of type {messageBase.GetType()} contains enum message type {messageBase.MessageType}" +
                                            $"which is not supported");
            }

            var payload = wrapper.ToByteArray().ToHex(prefix: true);

            return(payload);
        }
示例#27
0
        public bool SendToClient(int connectionId, MessageBase msg, CallbackHandler callback = null)
        {
            if (transport.ServerActive())
            {
                NetworkWriter writer  = new NetworkWriter();
                int           msgType = GetId(default(MessageBase) != null ? typeof(MessageBase) : msg.GetType());
                writer.WriteUInt16((ushort)msgType);

                int callbackId = 0;
                if (callback != null)
                {
                    callbackId = ++callbackIdIndex; // pre-increment to ensure that id 0 is never used.
                    callbacks.Add(callbackId, new CallbackData()
                    {
                        callback = callback, timeout = Time.realtimeSinceStartup + callbackTimeout
                    });
                }

                writer.WriteInt32(callbackId);

                msg.Serialize(writer);

                return(connections[connectionId].Send(writer.ToArray()));
            }
            logger.LogError("Server.Send: not connected!", this);
            return(false);
        }
示例#28
0
        public async Task Received(MessageBase message)
        {
            _queue = GetQueueReference(message.GetType());

            await _queue.DeleteMessageAsync(new CloudQueueMessage("", message.QueueData.ToString()));
        }
示例#29
0
        public void StartListen()
        {
            // 打印状态日志
            _context.LogSession.Print(LogLevel.Debug, _context.SessionId,
                                      $"Downlink message processer started, thread:{Thread.CurrentThread.ManagedThreadId}.");

            // 首先接收RmtGenMessage
            _messageQueue = _context.MessageTransceiver.MessageQueue;
            MessageBase   message       = _messageQueue.WaitUntilMessageCome();
            RmtGenMessage rmtGenMessage = (RmtGenMessage)message;

            if (null == rmtGenMessage)
            {
                throw new TestflowRuntimeException(ModuleErrorCode.InvalidMessageReceived,
                                                   _context.I18N.GetFStr("InvalidMessageReceived", message.GetType().Name));
            }
            _context.RmtGenMessage = rmtGenMessage;

            while (!_context.Cancellation.IsCancellationRequested)
            {
                message = _messageQueue.WaitUntilMessageCome();
                if (null == message)
                {
                    continue;
                }
                switch (message.Type)
                {
                case MessageType.Ctrl:
                    ProcessControlMessage((ControlMessage)message);
                    break;

                case MessageType.Debug:
                    ProcessDebugMessage((DebugMessage)message);
                    break;

                case MessageType.Sync:
                    ProcessSyncMessage((ResourceSyncMessage)message);
                    break;

                case MessageType.CallBack:
                    ProcessCallBackMessage((CallBackMessage)message);
                    break;

                // 暂未在Master端实现发送RuntimeError消息的错误
                case MessageType.RmtGen:
                case MessageType.RuntimeError:
                case MessageType.Status:
                case MessageType.TestGen:
                default:
                    throw new TestflowRuntimeException(ModuleErrorCode.InvalidMessageReceived,
                                                       _context.I18N.GetFStr("InvalidMessageReceived", message.GetType().Name));
                }
            }
            _context.LogSession.Print(LogLevel.Debug, _context.SessionId,
                                      $"Downlink message processor stopped, Thread:{Thread.CurrentThread.ManagedThreadId}");
        }
示例#30
0
        public void Send(MessageBase msg, CallbackHandler callback)
        {
            if (!transport.ClientConnected())
            {
                logger.LogError("[InsightClient] - Client not connected!");
                return;
            }

            NetworkWriter writer  = new NetworkWriter();
            int           msgType = GetId(default(MessageBase) != null ? typeof(MessageBase) : msg.GetType());

            writer.WriteUInt16((ushort)msgType);

            int callbackId = 0;

            if (callback != null)
            {
                callbackId = ++callbackIdIndex; // pre-increment to ensure that id 0 is never used.
                callbacks.Add(callbackId, new CallbackData()
                {
                    callback = callback,
                    timeout  = Time.realtimeSinceStartup + callbackTimeout
                });
            }

            writer.WriteInt32(callbackId);

            msg.Serialize(writer);
            transport.ClientSend(0, new ArraySegment <byte>(writer.ToArray()));
        }
 public static void SendMessageToPlayer(ulong steamId, MessageBase message)
 {
     ConquestScript.Instance.ServerLogger.WriteVerbose("SendMessageToPlayer {0} {1} {2}.", steamId, message.Side, message.GetType().Name);
     message.Side = MessageSide.ClientSide;
     try
     {
         var xml = MyAPIGateway.Utilities.SerializeToXML(new MessageContainer()
         {
             Content = message
         });
         byte[] byteData = System.Text.Encoding.Unicode.GetBytes(xml);
         if (byteData.Length <= MAX_MESSAGE_SIZE)
         {
             MyAPIGateway.Multiplayer.SendMessageTo(ConquestConsts.ConnectionId, byteData, steamId);
         }
         else
         {
             SendMessageParts(byteData, MessageSide.ClientSide, steamId);
         }
     }
     catch (Exception ex)
     {
         ConquestScript.Instance.ClientLogger.WriteException(ex);
         //TODO: send exception detail to Server.
     }
 }
示例#32
0
 public void SendMessage(MessageBase message)
 {
     _uplinkMessenger.Send(message, _slaveContext.GetProperty <FormatterType>("EngineQueueFormat"),
                           message.GetType());
 }