public Frame EncodeMessage <TIn>(SocketRequestMessage <TIn> message) { byte[] data = Serialize.Serialize(message.Data); Debug.Log("SocketRequest Request: " + message.Data); Frame f = new Frame(512); f.PutShort(MessageQueueHandler.GetProtocolCMD(message.GetType())); byte[] encryptedData = Crypto.Encryption(data); f.PutBytes(encryptedData); f.End(); return(f); }
public Frame EncodeMessage <TIn>(SocketRequestMessage <TIn> message) { var type = message.GetType(); var protoAttribute = Attribute.GetCustomAttribute(type, typeof(ProtoAttribute), false) as ProtoAttribute; Debug.Log($"SocketRequest Request: MessageID: {protoAttribute.value} {protoAttribute.description}, MessageData: {message.Data.ToString()}"); byte[] data = Serialize.Serialize(message.Data); Frame f = new Frame32(512); f.PutInt(MessageQueueHandler.GetProtocolCMD(message.GetType())); byte[] encryptedData = Crypto.Encryption(data); f.PutBytes(encryptedData); f.End(); return(f); }
private void Send(object param) { MemoryStream stream = new MemoryStream(); ProtoBuf.Serializer.NonGeneric.Serialize(stream, param); byte[] bs = stream.ToArray(); Frame f = null; if (socket.getProtocal().GetType() == typeof(Varint32HeaderProtocol)) { f = new Varint32Frame(512); } else { f = new Frame(512); } f.PutShort(MessageQueueHandler.GetProtocolCMD(param.GetType())); Debug.LogWarning("上行 cmd=" + MessageQueueHandler.GetProtocolCMD(param.GetType()) + ", type=" + param.GetType().ToString() + ", " + Time.fixedTime); Statics.SetXor(bs); f.PutBytes(bs); f.End(); socket.Send(f); }