Ejemplo n.º 1
0
 internal ReinNetMessageHolder(ReinNetMessage message, NetworkMessageData context)
 {
     this.message = message;
     if (this.message == null)
     {
         Main.LogF("Placeholder1");
         return;
     }
     this.messageType = message.GetType().ToString();
     if (!NT_messageLookup.ContainsKey(this.messageType))
     {
         Main.LogF("Placeholder2");
         return;
     }
     this.handler = NT_messageLookup[this.messageType];
     if (this.handler == null)
     {
         Main.LogF("Placeholder3");
         return;
     }
     this.contextData = context;
     if (this.contextData == null)
     {
         Main.LogF("Placeholder4");
         return;
     }
     this.safeToSend = true;
 }
Ejemplo n.º 2
0
 public override void Deserialize(NetworkReader reader)
 {
     this.safeToSend = reader.ReadBoolean();
     if (!this.safeToSend)
     {
         Main.LogF("Placeholder6");
         return;
     }
     this.messageType = reader.ReadString();
     this.contextData = NetworkMessageData.Read(reader);
     if (NT_messageLookup.ContainsKey(this.messageType))
     {
         this.handler = NT_messageLookup[this.messageType];
     }
     else
     {
         this.handler = null;
         Main.LogF("Unregistered message type: " + this.messageType + " recieved.\nThis means that the message was not fully Deserialized, and may cause other networking issues.");
         return;
     }
     this.message = this.handler?.Deserialize(reader);
 }
Ejemplo n.º 3
0
            public void Send(Dest destination = Dest.All, Boolean authority = false)
            {
                this.context = new NetworkMessageData(authority);

                var holder = new ReinNetMessageHolder(this, this.context);

                if (!holder.safeToSend)
                {
                    Main.LogF("PlaceholderPi");
                    return;
                }

                if (this.context.fromServer && (destination & Dest.Server) > Dest.None)
                {
                    foreach (NetworkConnection connection in NetworkServer.connections)
                    {
                        connection.SendByChannel(NT_messageIndex, holder, (Int32)QosType.Reliable);
                    }
                }
                if (this.context.fromClient && (destination & Dest.Client) > Dest.None)
                {
                    ClientScene.readyConnection.SendByChannel(NT_messageIndex, holder, (Int32)QosType.Reliable);
                }
            }