public bool Parse(PacketEvent packet) { this.valid = false; DataBuffer rawInput = new DataBuffer(packet.GetData(), packet.GetLength()); DataBufferReader reader = new DataBufferReader(); int protocol = reader.Read16(rawInput); if (protocol == 0xffff) { command = commandMap.GetValueOrDefault <int, AppleMIDICommand>(reader.Read16(rawInput)); switch (command) { case AppleMIDICommand.INVITATION: case AppleMIDICommand.INVITATION_ACCEPTED: case AppleMIDICommand.INVITATION_REJECTED: case AppleMIDICommand.END: this.valid = true; protocol_version = reader.ReadInteger(rawInput); initiator_token = reader.ReadInteger(rawInput); ssrc = reader.ReadInteger(rawInput); name = reader.ReadString(rawInput); // this.version = buffer.readUInt32BE(4); // this.token = buffer.readUInt32BE(8); // this.ssrc = buffer.readUInt32BE(12); // this.name = buffer.toString('utf-8', 16); break; case AppleMIDICommand.SYNCHRONIZATION: this.valid = true; ssrc = reader.ReadInteger(rawInput); count = reader.Read8(rawInput); padding = reader.Read24(rawInput); timestamp1 = reader.ReadUnsignedInteger64(rawInput); timestamp2 = reader.ReadUnsignedInteger64(rawInput); timestamp3 = reader.ReadUnsignedInteger64(rawInput); // this.ssrc = buffer.readUInt32BE(4, 8); // this.count = buffer.readUInt8(8); // this.padding = (buffer.readUInt8(9) << 0xF0) + buffer.readUInt16BE(10); // this.timestamp1 = buffer.slice(12, 20); //[buffer.readUInt32BE(12), buffer.readUInt32BE(16)]; // this.timestamp2 = buffer.slice(20, 28); //[buffer.readUInt32BE(20), buffer.readUInt32BE(24)]; // this.timestamp3 = buffer.slice(28, 36); //[buffer.readUInt32BE(28), buffer.readUInt32BE(32)]; break; case AppleMIDICommand.RECEIVER_FEEDBACK: this.valid = true; ssrc = reader.ReadInteger(rawInput); sequenceNumber = reader.Read16(rawInput); // this.ssrc = buffer.readUInt32BE(4, 8); // this.sequenceNumber = buffer.readUInt16BE(8); break; case AppleMIDICommand.BITRATE_RECEIVE_LIMIT: this.valid = true; break; } } return(valid); }
public Entity Deserialize(ref DataBufferReader data) { var entity = World.Mgr.CreateEntity(); var str = data.ReadString(); var type = Type.GetType(str); CreateComponent(type, entity, ref data); return(entity); }
private void OnReceivePlayer(TransportConnection connection, ref DataBufferReader reader) { var count = reader.ReadValue <int>(); for (var i = 0; i != count; i++) { var id = reader.ReadValue <int>(); var type = reader.ReadString(); playerManager.Register(connection, id, type); } }