Ejemplo n.º 1
0
        private KeyValuePair <EventData, SendParameters> SerializeMessage(INetworkMessage message, bool reliable, byte channel)
        {
            var messageData = serializer.ToMessageData(message);

            if (messageData.Value != null)
            {
                return(new KeyValuePair <EventData, SendParameters>(new EventData(messageData.Key, messageData.Value), new SendParameters()
                {
                    Unreliable = !reliable, ChannelId = channel
                }));
            }

            return(new KeyValuePair <EventData, SendParameters>(null, new SendParameters()));
        }
Ejemplo n.º 2
0
        protected void SendToServer(INetworkMessage message, bool reliable, byte channel)
        {
            var baseMessage = message as NetworkMessageBase;

            if (baseMessage != null)
            {
                baseMessage.PlayerName = playerName;
            }

            if (selfPeer != null)
            {
                var messageData = serializer.ToMessageData(message);

                if (messageData.Value != null)
                {
                    selfPeer.OpCustom(messageData.Key, messageData.Value, reliable, channel);
                }
            }
        }