public void Send(Guid guid, TransitionMessage message, bool isRequest) { CustomDataWriter writer = new CustomDataWriter(); writer.WriteBoolean(isRequest); byte[] guidDatas = guid.ToByteArray(); writer.WriteInt(guidDatas.Length); writer.WriteBytes(guidDatas); message.Pack(writer); var packet = writer.Data; Send(packet); if (SSyncCore.ShowProtocolMessage) { logger.Color2(string.Format("Send {0}", message.ToString())); } }
public void Add(object obj, bool isVar = false) { switch (obj) { case byte byteArg: _writer.WriteByte(byteArg); break; case sbyte sbyteArg: _writer.WriteSByte(sbyteArg); break; case ushort ushortArg: if (isVar) { _writer.WriteVarUShort(ushortArg); } else { _writer.WriteUShort(ushortArg); } break; case short shortArg: if (isVar) { _writer.WriteVarShort(shortArg); } else { _writer.WriteShort(shortArg); } break; case uint uintArg: if (isVar) { _writer.WriteVarUInt(uintArg); } else { _writer.WriteUInt(uintArg); } break; case int intArg: if (isVar) { _writer.WriteVarInt(intArg); } else { _writer.WriteInt(intArg); } break; case ulong ulongArg: if (isVar) { _writer.WriteVarULong(ulongArg); } else { _writer.WriteULong(ulongArg); } break; case long longArg: if (isVar) { _writer.WriteVarLong(longArg); } else { _writer.WriteLong(longArg); } break; case bool boolArg: _writer.WriteBool(boolArg); break; case float singleArg: _writer.WriteSingle(singleArg); break; case double doubleArg: _writer.WriteDouble(doubleArg); break; case string utfArg: _writer.WriteUTF(utfArg); break; } }