/// <summary> /// Send when player has succesfully connected to room /// </summary> public static void Send_RoomList(long connectionId, RoomInstance[] rooms) { //New packet ByteBuffer buffer = new ByteBuffer(); //Add packet id buffer.WriteLong((long)ServerPacketId.RoomList); //Add room list length buffer.WriteInteger(rooms.Length); //add rooms foreach (var room in rooms) { //add room id buffer.WriteLong(room.RoomId); //add max players in room buffer.WriteInteger(room.MaxPlayers); //add deck size buffer.WriteInteger(room.DeckSize); //add players count buffer.WriteInteger(room.ConnectedPlayersN); //add player names and avatars foreach (var name in room.GetPlayerNicknames()) { buffer.WriteStringUnicode(name); //using unicode there because player names support all languages } } //Send packet SendDataTo(connectionId, buffer.ToArray()); }
public override void Encode(ByteBuffer bb) { bb.WriteLong(Term); bb.WriteString(CandidateId); bb.WriteLong(LastLogIndex); bb.WriteLong(LastLogTerm); }
public static void Send_EndGameFool(long connectionId, long foolPlayerId, Dictionary <long, double> rewards) { //New packet ByteBuffer buffer = new ByteBuffer(); //Add packet id buffer.WriteLong((long)ServerPacketId.EndGameFool); //Add foolPlayerId buffer.WriteLong(foolPlayerId); //Add rewards count buffer.WriteInteger(rewards.Count); //Add rewards foreach (var reward in rewards) { //Add player id buffer.WriteLong(reward.Key); //Add player reward buffer.WriteDouble(reward.Value); } //Send packet SendDataTo(connectionId, buffer.ToArray()); }
public void Encode(ByteBuffer bb) { bb.WriteLong(Term); bb.WriteLong(Index); bb.WriteInt4(Log.TypeId); Log.Encode(bb); }
void sure(GameObject container, bool flag) { Transform level = container.transform.FindChild("level"); UIToggle good = level.FindChild("good").GetComponent <UIToggle>(); UIToggle normal = level.FindChild("normal").GetComponent <UIToggle>(); byte type = (byte)(good.value ? 3 : (normal ? 2 : 1)); UIInput inputFiled = container.transform.FindChild("inputer").GetComponent <UIInput>(); if (MyUtilTools.stringIsNull(inputFiled.value)) { UILabel label = inputFiled.transform.FindChild("tips").GetComponent <UILabel>(); DialogUtil.tip(label.text); return; } ByteBuffer buffer = ByteBuffer.Allocate(1024); buffer.skip(4); buffer.WriteString("Appraise"); buffer.WriteByte((byte)(flag?1:0)); buffer.WriteLong(order.dealId); buffer.WriteLong(order.id); buffer.WriteByte(type); buffer.WriteString(inputFiled.value); NetUtil.getInstance.SendMessage(buffer); }
public static void Send_UpdateUserData(long connectionId) { //New packet ByteBuffer buffer = new ByteBuffer(); //Add packet id buffer.WriteLong((long)ServerPacketId.UpdateUserData); Client client = ClientManager.GetConnectedClient(connectionId); //Add current connection id buffer.WriteLong(connectionId); //Add userId buffer.WriteLong(client.UserData.UserId); //Add client's display name buffer.WriteStringUnicode(client.UserData.Nickname); //Add client's money buffer.WriteDouble(client.UserData.Money); //Add client's avatar file URL string avatarUrl = client.UserData.AvatarFileUrl; buffer.WriteString(avatarUrl); //Send packet SendDataTo(connectionId, buffer.ToArray()); }
public void Pack(ByteBuffer writer) { // Base32Encoder base32 = new Base32Encoder(); // writer.WriteBytes(base32.Decode(actor)); // writer.WriteBytes(base32.Decode(permission)); writer.WriteLong(Base32.Decode(actor)); writer.WriteLong(Base32.Decode(permission)); }
public void ShouldWriteLong() { byteBuffer.WriteLong(inputLong); byte[] longByteLength = new byte[sizeof(long)]; int bufferLength = byteBuffer.Length(); Assert.Equal(bufferLength, longByteLength.Length); }
void tryToLoadDeal(MainData.SimpleOrderModule module) { ByteBuffer buffer = ByteBuffer.Allocate(1024); buffer.skip(4); buffer.WriteString("LookDealOrder"); buffer.WriteLong(module.dealId); buffer.WriteLong(module.orderId);//编号 NetUtil.getInstance.SendMessage(buffer); }
void _revoke() { ByteBuffer buffer = ByteBuffer.Allocate(1024); buffer.skip(4); buffer.WriteString("OrderRevoke"); buffer.WriteLong(MainData.instance.user.id); buffer.WriteLong(order.item.id); buffer.WriteLong(order.id); NetUtil.getInstance.SendMessage(buffer); }
void doFriendPass(MainData.FriendBody friend) { ByteBuffer buffer = ByteBuffer.Allocate(1024); buffer.skip(4); buffer.WriteString("FriendPass"); buffer.WriteLong(MainData.instance.user.id);//编号 buffer.WriteLong(friend.fid); buffer.WriteByte(1); NetUtil.getInstance.SendMessage(buffer); }
void delDeal(DealBody item) { ConfirmUtil.TryToDispear(); ByteBuffer buffer = ByteBuffer.Allocate(1024); buffer.skip(4); buffer.WriteString("DealDel"); buffer.WriteLong(item.id); buffer.WriteLong(MainData.instance.user.id); NetUtil.getInstance.SendMessage(buffer); }
void openLook(LongParamter dealId, LongParamter uid) { ByteBuffer buffer = ByteBuffer.Allocate(1024); buffer.skip(4); buffer.WriteString("UserLook"); buffer.WriteLong(dealId.Value); buffer.WriteLong(uid.Value); buffer.WriteLong(MainData.instance.user.id); NetUtil.getInstance.SendMessage(buffer); }
public void revokeOrder() { DealBody.Order order = orders[selectIndex]; ByteBuffer buffer = ByteBuffer.Allocate(1024); buffer.skip(4); buffer.WriteString("AdminOrderRevoke"); buffer.WriteLong(order.item.id); buffer.WriteLong(order.id); NetUtil.getInstance.SendMessage(buffer); }
void issueSure(DealBody item) { ConfirmUtil.TryToDispear(); ByteBuffer buffer = ByteBuffer.Allocate(1024); buffer.skip(4); buffer.WriteString("DealIssue"); buffer.WriteLong(item.id); buffer.WriteLong(item.uid); NetUtil.getInstance.SendMessage(buffer); }
void _revoke() { ConfirmUtil.TryToDispear(); DealBody.Order order = orders[selectIndex]; ByteBuffer buffer = ByteBuffer.Allocate(1024); buffer.skip(4); buffer.WriteString("AdminOrderRevoke"); buffer.WriteLong(order.item.id); buffer.WriteLong(order.id); NetUtil.getInstance.SendMessage(buffer); }
void delRevertSure(RevertDel revert) { ConfirmUtil.TryToDispear(); ByteBuffer buffer = ByteBuffer.Allocate(1024); buffer.skip(4); buffer.WriteString("RevertDel"); buffer.WriteLong(revert.id); buffer.WriteLong(MainData.instance.user.id); buffer.WriteLong(revert.fatherId); NetUtil.getInstance.SendMessage(buffer); }
/// <summary> /// I want to join any room without parameters /// </summary> public static void Send_JoinRoom(long roomId) { ByteBuffer buffer = new ByteBuffer(); //Write packet id buffer.WriteLong((long)ClientPacketId.JoinRoom); //write room id buffer.WriteLong(roomId); SendDataToServer(buffer.ToArray()); }
public static void SendAnimationData(int syncID, string id) { ByteBuffer buffer = new ByteBuffer(); buffer.WriteLong((long)PacketType.SyncAnimation); buffer.WriteLong((long)AnimationType.Trigger); buffer.WriteInteger(syncID); buffer.WriteString(id); SendData(buffer.ToArray()); buffer.Dispose(); }
/// <summary> /// Send when player has succesfully connected to room /// </summary> public static void Send_JoinRoomOk(long connectionId, long roomId) { //New packet ByteBuffer buffer = new ByteBuffer(); //Add packet id buffer.WriteLong((long)ServerPacketId.JoinRoomOk); //Add roomId buffer.WriteLong(roomId); //Send packet SendDataTo(connectionId, buffer.ToArray()); }
void _fk() { ConfirmUtil.TryToDispear(); ByteBuffer buffer = ByteBuffer.Allocate(1024); buffer.skip(4); buffer.WriteString("DealOrderUpdate"); buffer.WriteLong(order.dealId); buffer.WriteLong(order.id); buffer.WriteLong(MainData.instance.user.id); buffer.WriteByte(1); NetUtil.getInstance.SendMessage(buffer); }
public override void Encode(ByteBuffer bb) { bb.WriteLong(Term); bb.WriteString(LeaderId); bb.WriteLong(LastIncludedIndex); bb.WriteLong(LastIncludedTerm); bb.WriteLong(Offset); bb.WriteBinary(Data); bb.WriteBool(Done); bb.WriteBinary(LastIncludedLog); }
public static void SendSyncPosition(int syncObjID, NetworkObjectType type, Vector3 pos) { ByteBuffer buffer = new ByteBuffer(); buffer.WriteLong((long)PacketType.SyncPosition); buffer.WriteLong((long)type); buffer.WriteInteger(syncObjID); buffer.WriteFloat(pos.x); buffer.WriteFloat(pos.y); buffer.WriteFloat(pos.z); SendData(buffer.ToArray()); buffer.Dispose(); }
public void Pack(ByteBuffer writer) { //Base32Encoder base32 = new Base32Encoder(); writer.WriteLong(Base32.Decode(account)); writer.WriteLong(Base32.Decode(name)); //writer.WriteBytes(base32.Decode(name)); writer.WriteVariableUInt(authorization.Count); for (int i = 0; i < authorization.Count; i++) { authorization[i].Pack(writer); } byte[] decodedData = ByteBuffer.HexStringToBytes(data); writer.WriteVariableUInt(decodedData.Length); writer.WriteBytes(decodedData); }
public override void Encode(ByteBuffer bb) { bb.WriteLong(Term); bb.WriteString(LeaderId); bb.WriteLong(PrevLogIndex); bb.WriteLong(PrevLogTerm); bb.WriteInt(Entries.Count); foreach (var e in Entries) { bb.WriteBinary(e); } bb.WriteLong(LeaderCommit); }
public static void SendAnimationData(int syncID, string id, float value) { ByteBuffer buffer = new ByteBuffer(); buffer.WriteLong((long)PacketType.SyncAnimation); buffer.WriteLong((long)AnimationType.Float); buffer.WriteInteger(syncID); buffer.WriteString(id); buffer.WriteFloat(value); //This is the float value for SetFloat SendData(buffer.ToArray()); buffer.Dispose(); }
public static void SendNetSpawnRequest(int connectionID, string slug, float x, float y, float z, float rotX, float rotY, float rotZ, float rotW) { _data.RegisterObject(slug, x, y, z, rotX, rotY, rotZ, rotW); ByteBuffer buffer = new ByteBuffer(); buffer.WriteLong((long)PacketType.NetSpawn); buffer.WriteInteger(_data.Index); buffer.WriteString(slug); buffer.WriteFloat(x); buffer.WriteFloat(y); buffer.WriteFloat(z); buffer.WriteFloat(rotX); buffer.WriteFloat(rotY); buffer.WriteFloat(rotZ); buffer.WriteFloat(rotW); Console.WriteLine(_data.Index); SendDataToAll(buffer.ToArray()); buffer.Dispose(); }
public static void SendSpawnedObjects(int connectionID) { ByteBuffer buffer = new ByteBuffer(); for (int i = 0; i < _data.Index; i++) { SpawnedPrefab sp = _data.spawnedPrefabs[i]; buffer.WriteLong((long)PacketType.NetSpawn); buffer.WriteInteger(sp.assignedID); buffer.WriteString(sp.slug); buffer.WriteFloat(sp.transform.position.x); buffer.WriteFloat(sp.transform.position.y); buffer.WriteFloat(sp.transform.position.z); buffer.WriteFloat(sp.transform.rotation.x); buffer.WriteFloat(sp.transform.rotation.y); buffer.WriteFloat(sp.transform.rotation.z); buffer.WriteFloat(sp.transform.rotation.w); SendDataTo(connectionID, buffer.ToArray()); buffer.Dispose(); } }
public void change() { Transform container = needshow[0].transform.FindChild("scroll").FindChild("body").FindChild("container"); UISprite icon = container.FindChild("icon").GetComponent <UISprite>(); UILabel signature_save = container.FindChild("signature").FindChild("save").GetComponent <UILabel>(); UIInput name = container.FindChild("name").FindChild("inputer").GetComponent <UIInput>(); UIInput indent = container.FindChild("indent").FindChild("inputer").GetComponent <UIInput>(); UIToggle toggle = container.FindChild("push-flag").FindChild("toggle").GetComponent <UIToggle>(); ByteBuffer buffer = ByteBuffer.Allocate(1024); buffer.skip(4); buffer.WriteString("UserUpdate"); buffer.WriteLong(MainData.instance.user.id);//编号 buffer.WriteString(icon.spriteName); buffer.WriteString(signature_save.text); buffer.WriteByte((byte)(toggle.value ? 1 : 0)); if (!MyUtilTools.stringIsNull(name.value)) { buffer.WriteString(name.value); } else { buffer.WriteString(""); } if (!MyUtilTools.stringIsNull(indent.value)) { buffer.WriteString(indent.value); } else { buffer.WriteString(""); } NetUtil.getInstance.SendMessage(buffer); }
private void Start() { pb.PlayerSnapShootMsg msg = new pb.PlayerSnapShootMsg(); msg.username = "******"; msg.playerId = 9000001; byte[] data = ProtobufSerializer.Serialize(msg); Debug.LogError("data len " + data.Length); ByteBuffer buffer = ByteBuffer.Allocate(1024); buffer.WriteShort(1001); buffer.WriteShort(1002); buffer.WriteShort(1003); buffer.WriteLong(10055555); buffer.WriteBytes(data); short s1 = buffer.ReadShort(); short s2 = buffer.ReadShort(); short s3 = buffer.ReadShort(); long l1 = buffer.ReadLong(); byte[] readData = new byte[buffer.ReadableBytes()]; buffer.ReadBytes(readData, 0, buffer.ReadableBytes()); Debug.LogError("readData len " + readData.Length); pb.PlayerSnapShootMsg dmsg = ProtobufSerializer.DeSerialize <pb.PlayerSnapShootMsg>(readData); Debug.LogError("user name " + dmsg.username); //socket receive bytes // }