public override void ToNetworkMessage(NetworkMessage msg) { msg.AddByte((byte)Type); msg.AddByte(Slot); msg.AddItem(Item); }
public override void ToNetworkMessage(NetworkMessage msg) { msg.AddByte((byte)Type); msg.AddLocation(Location); msg.AddByte((byte)Color); msg.AddString(Message); }
public override void ToNetworkMessage(NetworkMessage msg) { msg.AddByte((byte)Type); msg.AddLocation(FromPosition); msg.AddLocation(ToPosition); msg.AddByte((byte)Effect); }
public override void ToNetworkMessage(NetworkMessage msg) { msg.AddByte((byte)Type); msg.AddLocation(FromLocation); msg.AddByte(FromStackPosition); msg.AddLocation(ToLocation); }
public void AddMessageToSend(NetworkMessage mes) { lock (messageQueue) { messageQueue.Enqueue(mes); } }
public static void OnSetupWeapon(NetworkMessage netMsg) { var msg = netMsg.ReadMessage<WeaponSetupMessage>(); var weaponPickup = msg.weapon.GetComponent<WeaponPickup>(); weaponPickup.PickupWeapon(msg.player); }
public override void ToNetworkMessage(NetworkMessage msg) { msg.AddByte((byte)Type); msg.AddUInt32(CreatureId); msg.AddByte(LightLevel); msg.AddByte(LightColor); }
public override bool ParseMessage(NetworkMessage msg, PacketDestination destination, NetworkMessage outMsg) { if (msg.GetByte() != (byte)IncomingPacketType.TileUpdate) return false; Destination = destination; Type = IncomingPacketType.TileUpdate; outMsg.AddByte((byte)Type); Objects.Location pos = msg.GetLocation(); outMsg.AddLocation(pos); ushort thingId = msg.PeekUInt16(); if (thingId == 0xFF01) { outMsg.AddUInt16(msg.GetUInt16()); } else { ParseTileDescription(msg, pos, outMsg); outMsg.AddUInt16(msg.GetUInt16()); } return true; }
public static void OnSetupGameOver(NetworkMessage netMsg) { var msg = netMsg.ReadMessage<PlayerMessage>(); var gameOver = msg.player.GetComponent<PlayerRespawn>(); gameOver.anim = GameObject.Find("HUDCanvas").GetComponent<Animator>(); }
public string SendRequest() { var message = new NetworkService().SendMessage(); var networkMessage = new NetworkMessage((Status)message.Item1, message.Item2); return networkMessage.IsSuccess().ToString() + " " + networkMessage.GetContentAs<string>(); }
void OnConnected(NetworkMessage msg) { Debug.Log (string.Format("Connected to Server")); connectionIdMessage connIdMsg = new connectionIdMessage (); connIdMsg.setConnId (client.connection.connectionId); client.Send(Message.GET_HAS_ROOM, connIdMsg); }
private void OnCreateChannelResponse(NetworkMessage netMsg) { Debug.Log ("OnCreateChannelResponse"); var response_message = netMsg.ReadMessage<CreateChannelResponseMessage>(); if(response_message.Created) { GameObject new_object = Instantiate (chat_content_prefab) as GameObject; Transform new_transform = new_object.transform; new_transform.SetParent (chat_window_transform, false); channel_transform_connections.Add (new ChannelTransformConnection() { ChannelId = response_message.ChannelId, ChatContentTransform = new_transform }); channel_dropdown.AddOptions( new List<string>() {response_message.ChannelId}); current_channel_id = response_message.ChannelId; channel_dropdown.value = channel_dropdown.options.Count-1; //select the new room send_button.interactable = true; input_text_field.interactable = true; } }
public override bool ParseMessage(NetworkMessage msg, PacketDestination destination) { int position = msg.Position; if (msg.GetByte() != (byte)IncomingPacketType.ChannelOpen) return false; Destination = destination; Type = IncomingPacketType.ChannelOpen; ChannelId = (ChatChannel)msg.GetUInt16(); ChannelName = msg.GetString(); if (Client.VersionNumber >= 872) { NumberOfParticipants = msg.GetUInt16(); for (ushort p = 0; p < NumberOfParticipants; p++) { Participants[p] = msg.GetString(); } NumberOfInvitees = msg.GetUInt16(); for (ushort i = 0; i < NumberOfInvitees; i++) { Invitees[i] = msg.GetString(); } } return true; }
void ConnectReact(NetworkMessage mes) { netController.client.UnregisterHandler (MsgType.Connect); netController.client.UnregisterHandler (MsgType.Disconnect); netController.client.UnregisterHandler (MsgType.Error); SceneManager.LoadScene ("game"); }
public override bool ParseMessage(NetworkMessage msg, PacketDestination destination) { if (msg.GetByte() != (byte)OutgoingPacketType.AutoWalk) return false; Destination = destination; Type = OutgoingPacketType.AutoWalk; Directions = new List<Pokemon.Constants.Direction> { }; byte count = msg.GetByte(); for (int i = 0; i < count; i++) { Constants.Direction direction; byte dir = msg.GetByte(); switch (dir) { case 1: direction = Pokemon.Constants.Direction.Right; break; case 2: direction = Pokemon.Constants.Direction.UpRight; break; case 3: direction = Pokemon.Constants.Direction.Up; break; case 4: direction = Pokemon.Constants.Direction.UpLeft; break; case 5: direction = Pokemon.Constants.Direction.Left; break; case 6: direction = Pokemon.Constants.Direction.DownLeft; break; case 7: direction = Pokemon.Constants.Direction.Down; break; case 8: direction = Pokemon.Constants.Direction.DownRight; break; default: continue; } Directions.Add(direction); } return true; }
public override bool ParseMessage(NetworkMessage msg, PacketDestination destination) { int position = msg.Position; if (msg.GetByte() != (byte)IncomingPacketType.TileTransformThing) return false; Destination = destination; Type = IncomingPacketType.TileTransformThing; Position = msg.GetLocation(); StackPosition = msg.GetByte(); ThingId = msg.GetUInt16(); if (ThingId == 0x0061 || ThingId == 0x0062 || ThingId == 0x0063) { CreatureId = msg.GetUInt32(); CreatureDirection = msg.GetByte(); } else { Item = new Pokemon.Objects.Item(Client, ThingId, 0); Item.Location = Pokemon.Objects.ItemLocation.FromLocation(Position); if (Item.HasExtraByte) Item.Count = msg.GetByte(); } return true; }
public override bool ParseMessage(NetworkMessage msg, PacketDestination destination) { int position = msg.Position; if (msg.GetByte() != (byte)IncomingPacketType.OutfitWindow) return false; Destination = destination; Type = IncomingPacketType.OutfitWindow; Default = msg.GetOutfit(); byte count = msg.GetByte(); OutfitList = new List<AvalibleOutfit> { }; for (int i = 0; i < count; i++) { AvalibleOutfit outfit = new AvalibleOutfit(); outfit.Id = msg.GetUInt16(); outfit.Name = msg.GetString(); outfit.Addons = msg.GetByte(); OutfitList.Add(outfit); } return true; }
public void OnServerRegisterDeath(NetworkMessage msg) { KillPlayer kp = msg.ReadMessage<KillPlayer>(); GameObject obj = NetworkServer.FindLocalObject(kp.netId); // Relay msg to player if(obj == null) return; NetworkServer.SendToClientOfPlayer(obj, Msgs.killPlayer, kp); }
public override bool ParseMessage(NetworkMessage msg, PacketDestination destination) { int position = msg.Position; if (msg.GetByte() != (byte)IncomingPacketType.PlayerSkillsUpdate) return false; Destination = destination; Type = IncomingPacketType.PlayerSkillsUpdate; Fist = msg.GetByte(); FistPercent = msg.GetByte(); Club = msg.GetByte(); ClubPercent = msg.GetByte(); Sword = msg.GetByte(); SwordPercent = msg.GetByte(); Axe = msg.GetByte(); AxePercent = msg.GetByte(); Distance = msg.GetByte(); DistancePercent = msg.GetByte(); Shield = msg.GetByte(); ShieldPercent = msg.GetByte(); Fish = msg.GetByte(); FishPercent = msg.GetByte(); return true; }
public override bool ParseMessage(NetworkMessage msg, PacketDestination destination, NetworkMessage outMsg) { int msgPosition = msg.Position, outMsgPosition = outMsg.Position; if (msg.GetByte() != (byte)IncomingPacketType.FloorChangeUp) return false; Destination = destination; Type = IncomingPacketType.FloorChangeUp; outMsg.AddByte((byte)Type); Client.playerLocation.Z--; try { //going to surface if (Client.playerLocation.Z == 7) { //floor 7 and 6 already set for (int i = 5; i >= 0; i--) ParseFloorDescription(msg, Client.playerLocation.X - 8, Client.playerLocation.Y - 6, i, 18, 14, 8 - i, outMsg); } //underground, going one floor up (still underground) else if (Client.playerLocation.Z > 7) ParseFloorDescription(msg, Client.playerLocation.X - 8, Client.playerLocation.Y - 6, Client.playerLocation.Z - 2, 18, 14, 3, outMsg); return true; } finally { Client.playerLocation.X++; Client.playerLocation.Y++; } }
protected bool ParseMapDescription(NetworkMessage msg, int x, int y, int z, int width, int height, NetworkMessage outMsg) { int startz, endz, zstep; //calculate map limits if (z > 7) { startz = z - 2; endz = System.Math.Min(16 - 1, z + 2); zstep = 1; } else { startz = 7; endz = 0; zstep = -1; } for (int nz = startz; nz != endz + zstep; nz += zstep) { if (!ParseFloorDescription(msg, x, y, nz, width, height, z - nz, outMsg)) return false; } return true; }
public static void Handle(NetworkMessage message) { switch (message.MessageType) { case NetworkMessageType.Connect: HandleConnect(message as ConnectMessage); break; case NetworkMessageType.StartGame: HandleStartGame(message as StartGameMessage); break; case NetworkMessageType.HitBall: HandleHitBall(message as HitBallMessage); break; case NetworkMessageType.CreateBall: HandleCreateBall(message as CreateBallMessage); break; case NetworkMessageType.LostBall: HandleLostBall(message as LostBallMessage); break; case NetworkMessageType.LevelUpBegin: HandleLevelUpBegin(message as LevelUpBeginMessage); break; case NetworkMessageType.LevelUpEnd: HandleLevelUpEnd(message as LevelUpEndMessage); break; case NetworkMessageType.EndGame: HandleEndGame(message as EndGameMessage); break; case NetworkMessageType.WaitForGame: HandleWaitForGame(message as WaitForGameMessage); break; } }
public override bool ParseMessage(NetworkMessage msg, PacketDestination destination) { int position = msg.Position; if (msg.GetByte() != (byte)IncomingPacketType.ContainerOpen) return false; Destination = destination; Type = IncomingPacketType.ContainerOpen; Id = msg.GetByte(); ItemId = msg.GetUInt16(); Name = msg.GetString(); Capacity = msg.GetByte(); HasParent = msg.GetByte(); ItemCount = msg.GetByte(); Items = new List<Tibia.Objects.Item>(ItemCount); for (int i = 0; i < ItemCount; i++) { Objects.Item item = msg.GetItem(); item.Location = Tibia.Objects.ItemLocation.FromContainer(Id, (byte)i); Items.Add(item); } return true; }
void LogIn(NetworkMessage netMsg, InfoMessage msg) { bool loggedIn = false; string query = "SELECT * FROM shogi.players WHERE players_email = \"" + msg.email + "\""; if (con.State.ToString () != "Open") con.Open (); using (con) { using (cmd = new MySqlCommand (query, con)) { rdr = cmd.ExecuteReader(); if (rdr.HasRows) { rdr.Read (); if (msg.password == rdr["players_password"].ToString ()) { incomeMessages.text += netMsg.conn.address + " logged in as " + msg.email + "\n"; loggedIn = true; } else incomeMessages.text += netMsg.conn.address + " failed logging in for wrong password " + msg.password + "\n"; } else incomeMessages.text += netMsg.conn.address + " failed logging in for no entry " + msg.email + "\n"; rdr.Dispose (); } string queryIP = "UPDATE shogi.players SET players_ip = \"" + netMsg.conn.address + "\" WHERE players_email = \"" + msg.email + "\""; if (loggedIn) { using (cmd = new MySqlCommand (queryIP, con)) cmd.ExecuteNonQuery (); msg.goal = "loggedin"; NetworkServer.SendToClient(netMsg.conn.connectionId, MyMsgType.Info, msg); } } }
public override bool ParseMessage(NetworkMessage msg, PacketDestination destination) { int position = msg.Position; if (msg.GetByte() != (byte)IncomingPacketType.PlayerStatus) return false; Destination = destination; Type = IncomingPacketType.PlayerStatus; Health = msg.GetUInt16(); MaxHealth = msg.GetUInt16(); PokemonsCount = msg.GetUInt32(); Experience = msg.GetUInt32(); Level = msg.GetUInt16(); LevelPercent = msg.GetByte(); Pokemons = msg.GetUInt16(); PokemonsMax = msg.GetUInt16(); MagicLevel = msg.GetByte(); MagicLevelPercent = msg.GetByte(); Soul = msg.GetByte(); Stamina = msg.GetUInt16(); return true; }
public override void ToNetworkMessage(NetworkMessage msg) { msg.AddByte((byte)Type); msg.AddUInt32(PlayerId); msg.AddString(PlayerName); msg.AddByte(PlayerState); }
public override void ToNetworkMessage(NetworkMessage msg) { msg.AddByte((byte)Type); msg.AddUInt16(ChannelId); msg.AddString(Name); }
public static void OnPlayerExperience(NetworkMessage netMsg) { var msg = netMsg.ReadMessage<PlayerExperienceMessage>(); //Seems like the server is receiving the message as well FloatingTextManager.PlayerXp(msg.amount, msg.position); }
public override void ToNetworkMessage(NetworkMessage msg) { msg.AddByte((byte)Type); msg.AddUInt16(Health); msg.AddUInt16(MaxHealth); msg.AddUInt32(Capacity); if (Client.VersionNumber >= 870) { msg.AddUInt64(Experience); } else { msg.AddUInt32((uint)Experience); } msg.AddUInt16(Level); msg.AddByte(LevelPercent); msg.AddUInt16(Mana); msg.AddUInt16(MaxMana); msg.AddByte(MagicLevel); msg.AddByte(MagicLevelPercent); msg.AddByte(Soul); msg.AddUInt16(Stamina); }
public static void Send(NetworkMessage message, Action<byte[]> sendBytesMethod) { int headerSize = 8; byte[] messageCategoryBytes = UTF8Encoding.UTF8.GetBytes(message.MessageCategory); byte[] pipeBytes = UTF8Encoding.UTF8.GetBytes("|"); byte[] messageTypeBytes = UTF8Encoding.UTF8.GetBytes(message.MessageType); byte[] messageSpaceBytes = UTF8Encoding.UTF8.GetBytes(" "); byte[] messageContentBytes = UTF8Encoding.UTF8.GetBytes(message.MessageContent); int length = messageContentBytes.Length + messageSpaceBytes.Length + messageTypeBytes.Length + pipeBytes.Length + messageCategoryBytes.Length; byte[] headerBytes = new byte[headerSize]; headerBytes[0] = NetworkMessage.ProtocolHeader[0]; headerBytes[1] = NetworkMessage.ProtocolHeader[1]; headerBytes[2] = NetworkMessage.ProtocolMajorVersion; headerBytes[3] = NetworkMessage.ProtocolMinorVersion; for (int i = 7; i >= 4; i--) { headerBytes[i] = (byte)(length % 256); length /= 256; } sendBytesMethod(headerBytes); sendBytesMethod(messageCategoryBytes); sendBytesMethod(pipeBytes); sendBytesMethod(messageTypeBytes); sendBytesMethod(messageSpaceBytes); sendBytesMethod(messageContentBytes); }
public void SetWerewolf(NetworkMessage message) { msg.value = message.ReadMessage <StringMessage>().value; string[] deltas = msg.value.Split('|'); gamemng.GetComponent <ClientUI>().SetFangWerewolf(deltas); }
protected virtual void OnMessageSended(NetworkMessage message) { var handler = MessageSent; handler?.Invoke(this, message); }
protected virtual void OnMessageReceived(NetworkMessage message) { var handler = MessageReceived; handler?.Invoke(this, message); }
public bool Handler(ref NetworkMessage message) { throw new NotImplementedException(); }
public bool Handler(ref NetworkMessage message) { pParser((PacketSt466)message.PacketTemplate, message.PacketData); QueuingService.NetOutQueue.Enqueue(message); return(true); }
private void OnTeamIdReceived(NetworkMessage netmsg) { var msg = netmsg.ReadMessage <TeamIdMessage>(); _allyTeam = msg.TeamId; }
//RECEIVE FUNCTIONS public void ReceivePlayerName(NetworkMessage message) { msg.value = message.ReadMessage <StringMessage>().value; gamemng.GetComponent <ClientGameController>().UpdateName(msg.value); }
void OnClientError(NetworkMessage msg) { Debug.Log("Error"); }
public NetworkMessageReaderReadCompletedEventArgs(NetworkMessage netMessage, TcpClient tcpClient) { this.NetworkMessage = netMessage; this.TcpClient = tcpClient; }
public void SetChat(NetworkMessage message) { msg.value = message.ReadMessage <StringMessage>().value; string[] deltas = msg.value.Split('|'); pymng.GetComponent <ClientChat>().Reader(deltas[0], deltas[1]); }
private void PingCommand(NetworkMessage message) { Send(MessageProtocols.Pong, true); }
void OnClientDisconnect(NetworkMessage msg) { Debug.Log("Disconnected"); }
private static void OnMPTweaksSet(NetworkMessage rawMsg) { var msg = rawMsg.ReadMessage <TweaksMessage>(); MPTweaks.Set(msg.m_settings); }
private void EndCommand(NetworkMessage message) { Terminate(); }
/// <summary> /// Composes and sends a data message. /// </summary> /// <param name="entityId">Unique ID of the affected entity.</param> /// <param name="ownerId">The entity owner's NetworkId</param> /// <param name="payload">The state describing changes to the entity.</param> /// <param name="action">The type of message that determines the ultimate action taken.</param> /// <param name="method">The delivery method.</param> /// <param name="recipient">The recipient connection. Will send to all if null.</param> private void SendDataMessage(ulong id, object payload, NetworkMessageType action, NetConnection recipient = null) { int payloadTypeId = -1; Type type; NetDeliveryMethod method; switch (action) { // critical messages should be guaranteed delivery and in sequence case NetworkMessageType.Create: case NetworkMessageType.Destroy: case NetworkMessageType.Reckoning: method = NetDeliveryMethod.ReliableOrdered; break; // general updates can fail, reckoning cycle will correct missed messages case NetworkMessageType.Update: method = NetDeliveryMethod.UnreliableSequenced; break; default: method = NetDeliveryMethod.UnreliableSequenced; break; } if (payload != null) { try { // get the type and find it's ID in the config enumeration type = payload.GetType(); payloadTypeId = Configuration.EntityStateTypes.IndexOf(type); } catch (Exception ex) { throw new RedGrinException("Failed to get entity state.", ex); } // TODO: Not a fan of the negative type ID meaning "missing" - better solution here? if (payloadTypeId == -1) { throw new RedGrinException("Failed to find ID for type: " + type.ToString()); } } NetworkMessage message = new NetworkMessage(); message.Id = id; message.PayloadTypeId = payloadTypeId; message.MessageType = action; message.Payload = payload; NetOutgoingMessage outgoingMessage = network.CreateMessage(); message.Encode(outgoingMessage, ServerTime); switch (Role) { case NetworkRole.Server: if (recipient == null) { ((NetServer)network).SendToAll(outgoingMessage, method); } else { ((NetServer)network).SendMessage(outgoingMessage, recipient, method); } break; case NetworkRole.Client: var server = ((NetClient)network).ServerConnection; network.SendMessage(outgoingMessage, server, method); break; default: throw new RedGrinException("Attempted to send message as an unsupported role: " + Role.ToString()); } }
static void Postfix(NetworkMessage msg) { MPTweaks.ClientCapabilitiesRemove(msg.conn.connectionId); }
public override void ParseFromNetworkMessage(NetworkMessage message) { Text = message.ReadString(); Delay = message.ReadByte(); }
public void KickedMessageHandler(NetworkMessage netMsg) { infoPanel.Display("Kicked by Server", "Close", null); netMsg.conn.Disconnect(); }
public override void AppendToNetworkMessage(NetworkMessage message) { message.Write((byte)ClientPacketType.CloseNpcTrade); }
public override void AppendToNetworkMessage(NetworkMessage message) { message.Write((byte)ServerPacketType.LoginWait); message.Write(Text); message.Write(Delay); }
public void KickedVersionDifferent(NetworkMessage netMsg) { infoPanel.Display("Version mismatch", "Close", null); netMsg.conn.Disconnect(); }
public void UpdateMessagePump() { if (!server_started) { return; } int rec_host_id; //standalone vs web int client_id; //user int channel_id; //lane byte[] byte_buffer = new byte[BYTE_SIZE]; int data_size; NetworkEventType type = NetworkTransport.Receive(out rec_host_id, out client_id, out channel_id, byte_buffer, BYTE_SIZE, out data_size, out error); if (type != NetworkEventType.Nothing && type != NetworkEventType.BroadcastEvent) { //Debug.Log("Receive client ID: " + client_id); } switch (type) { case NetworkEventType.Nothing: break; case NetworkEventType.DataEvent: BinaryFormatter formatter = new BinaryFormatter(); MemoryStream memory_stream = new MemoryStream(byte_buffer); NetworkMessage message = (NetworkMessage)formatter.Deserialize(memory_stream); OnDataRecieved(client_id, channel_id, host_id, message); break; case NetworkEventType.ConnectEvent: Debug.Log("User connected with ID: " + client_id); current_user_amount++; AssignClientID(client_id); if (lobby) { gameObject.GetComponent <PlayerManager>().AddPlayerToList(client_id, PlayerManager.PlayerType.PLAYER); // add the player info to the list of players lobby.SetPlayerConnection(client_id, connection_status.connected); } break; case NetworkEventType.DisconnectEvent: Debug.Log("User Disconnected with ID: " + client_id); if (lobby) { gameObject.GetComponent <PlayerManager>().RemovePlayerFromList(client_id); // remove player from the list of players lobby.SetPlayerConnection(client_id, connection_status.disconnected); } current_user_amount--; break; default: case NetworkEventType.BroadcastEvent: Debug.Log("Incorrect Data type"); break; } }
private void OnError(NetworkMessage netMsg) { SetUpServer(); SetUpClient(_port); }
public void KickedServerFull(NetworkMessage netMsg) { infoPanel.Display("Server full", "Close", null); netMsg.conn.Disconnect(); }
private void OnOpenMenuState(NetworkMessage netMsg) { replayMenu.SetActive(false); gameMenu.SetActive(false); loadingMenu.SetActive(true); }
public void KickedHotJoinDisabled(NetworkMessage netMsg) { infoPanel.Display("Match is in session", "Close", null); netMsg.conn.Disconnect(); }
private void OnChangeReplayPlayingState(NetworkMessage netMsg) { throw new NotImplementedException(); }
private void OnOpenGameState(NetworkMessage netMsg) { loadingMenu.SetActive(false); gameMenu.SetActive(true); }
public void OnError(NetworkMessage netMsg) { Debug.Log("Error connecting with code " + netMsg); }
private void OnOpenReplayState(NetworkMessage netMsg) { loadingMenu.SetActive(false); replayMenu.SetActive(true); }