Пример #1
0
 void ITransportCallback.Receive(ByteStream source, ulong sender)
 {
     if (MySyncLayer.CheckReceivePermissions(sender, this.Permission))
     {
         TMsg local;
         try
         {
             this.m_serializer.Deserialize(source, out local);
         }
         catch (Exception exception)
         {
             MySandboxGame.Log.WriteLine(new Exception($"Error deserializing '{typeof(TMsg).Name}', message size '{source.Length}'", exception));
             return;
         }
         this.m_callback(ref local, sender);
     }
 }
Пример #2
0
        void ITransportCallback.Receive(ByteStream source, ulong sender, TimeSpan timestamp)
        {
            if (!MySyncLayer.CheckReceivePermissions(sender, Permission))
            {
                return;
            }

            TMsg msg;

            try
            {
                Serializer.Deserialize(source, out msg);
                MyTrace.Send(TraceWindow.Multiplayer, "Received control message: " + msg.ToString(), sender + ", " + source.Position + " B");
            }
            catch (Exception e)
            {
                // Catch, add more info (what message) and write to log
                MySandboxGame.Log.WriteLine(new Exception(String.Format("Error deserializing '{0}', message size '{1}'", typeof(TMsg).Name, source.Length), e));
                return;
            }

            Callback(ref msg, sender);
        }