public static byte[] BuildMessage(StateUpdateObject sup) { var fbb = new FlatBufferBuilder(1024); var supOffset = sup.ToBuffer(fbb); ServerMessage.StartServerMessage(fbb); ServerMessage.AddType(fbb, msgType.RoomStateUpdate); ServerMessage.AddDataType(fbb, msg.StateUpdate); ServerMessage.AddData(fbb, supOffset.Value); var builtMessage = ServerMessage.EndServerMessage(fbb); fbb.Finish(builtMessage.Value); return(fbb.SizedByteArray()); }
public static byte[] BuildMessage(string roomName, string usrName, string usrId, string devType) { var fbb = new FlatBufferBuilder(1024); var rmNameOffset = fbb.CreateString(roomName); var usrNameOffset = fbb.CreateString(usrName); var usrIdOffset = fbb.CreateString(usrId); var devTypeOffset = fbb.CreateString(devType); var jcRoomOffset = JoinCreateRequest.CreateJoinCreateRequest(fbb, rmNameOffset, usrNameOffset, usrIdOffset, devTypeOffset); ServerMessage.StartServerMessage(fbb); ServerMessage.AddType(fbb, msgType.SocketCreateOrJoinRoom); ServerMessage.AddDataType(fbb, msg.JoinCreateRequest); ServerMessage.AddData(fbb, jcRoomOffset.Value); var builtMessage = ServerMessage.EndServerMessage(fbb); fbb.Finish(builtMessage.Value); return(fbb.SizedByteArray()); }
public static byte[] BuildMessage(msgType type, string stringData) { var fbb = new FlatBufferBuilder(1024); switch (type) { case msgType.SocketCreateOrJoinRoom: var cjString = fbb.CreateString(stringData); var cjRoomOffset = StringData.CreateStringData(fbb, cjString); ServerMessage.StartServerMessage(fbb); ServerMessage.AddType(fbb, msgType.SocketCreateOrJoinRoom); ServerMessage.AddDataType(fbb, msg.StringData); ServerMessage.AddData(fbb, cjRoomOffset.Value); var builtMessage = ServerMessage.EndServerMessage(fbb); fbb.Finish(builtMessage.Value); return(fbb.SizedByteArray()); } return(null); }