Пример #1
0
 /// <summary>
 /// Writes the TickEvent data to the stream
 /// </summary>
 /// <param name="stream">The stream to write the TickEvent data to</param>
 public void SerializeToStream(Stream stream)
 {
     using (PooledBitWriter writer = PooledBitWriter.Get(stream))
     {
         writer.WriteByte((byte)EventType);
         writer.WriteUInt32Packed(Bytes);
         writer.WriteStringPacked(ChannelName);
         writer.WriteStringPacked(MessageType);
         writer.WriteBool(Closed);
     }
 }
Пример #2
0
        private static void LogServer(string message, LogType logType)
        {
            // Get the sender of the local log
            ulong localId = NetworkingManager.Singleton != null ? NetworkingManager.Singleton.LocalClientId : 0;

            switch (logType)
            {
            case LogType.Info:
                LogInfoServerLocal(message, localId);
                break;

            case LogType.Warning:
                LogWarningServerLocal(message, localId);
                break;

            case LogType.Error:
                LogErrorServerLocal(message, localId);
                break;
            }

            if (NetworkingManager.Singleton != null && !NetworkingManager.Singleton.IsServer && NetworkingManager.Singleton.NetworkConfig.EnableNetworkLogs)
            {
                using (PooledBitStream stream = PooledBitStream.Get())
                {
                    using (PooledBitWriter writer = PooledBitWriter.Get(stream))
                    {
                        writer.WriteByte((byte)logType);

                        writer.WriteStringPacked(message);

                        InternalMessageSender.Send(NetworkingManager.Singleton.ServerClientId, MLAPIConstants.MLAPI_SERVER_LOG, "MLAPI_INTERNAL", stream, SecuritySendFlags.None, null);
                    }
                }
            }
        }
Пример #3
0
 public static void RegisterSerialization()
 {
     SerializationManager.RegisterSerializationHandlers <ItemSlotNetworkedData>((Stream stream, ItemSlotNetworkedData instance) =>
     {
         using (PooledBitWriter writer = PooledBitWriter.Get(stream))
         {
             writer.WriteStringPacked(instance.itemId);
             writer.WriteInt32(instance.itemAmount);
         }
     }, (Stream stream) =>
     {
         using (PooledBitReader reader = PooledBitReader.Get(stream))
         {
             return(new ItemSlotNetworkedData(reader.ReadStringPacked().ToString(), reader.ReadInt32()));
         }
     });
 }