Ejemplo n.º 1
0
        public override void ToNetworkMessage(NetworkMessage msg)
        {
            msg.AddByte((byte)Type);
            msg.AddByte(Slot);

            msg.AddItem(Item);
        }
Ejemplo n.º 2
0
 public override void ToNetworkMessage(NetworkMessage msg)
 {
     msg.AddByte((byte)Type);
     msg.AddLocation(Location);
     msg.AddByte((byte)Color);
     msg.AddString(Message);
 }
Ejemplo n.º 3
0
 public override void ToNetworkMessage(NetworkMessage msg)
 {
     msg.AddByte((byte)Type);
     msg.AddLocation(FromPosition);
     msg.AddLocation(ToPosition);
     msg.AddByte((byte)Effect);
 }
Ejemplo n.º 4
0
 public override void ToNetworkMessage(NetworkMessage msg)
 {
     msg.AddByte((byte)Type);
     msg.AddLocation(FromLocation);
     msg.AddByte(FromStackPosition);
     msg.AddLocation(ToLocation);
 }
Ejemplo n.º 5
0
 public void AddMessageToSend(NetworkMessage mes)
 {
     lock (messageQueue)
     {
         messageQueue.Enqueue(mes);
     }
 }
Ejemplo n.º 6
0
    public static void OnSetupWeapon(NetworkMessage netMsg)
    {
        var msg = netMsg.ReadMessage<WeaponSetupMessage>();

        var weaponPickup = msg.weapon.GetComponent<WeaponPickup>();
        weaponPickup.PickupWeapon(msg.player);
    }
Ejemplo n.º 7
0
 public override void ToNetworkMessage(NetworkMessage msg)
 {
     msg.AddByte((byte)Type);
     msg.AddUInt32(CreatureId);
     msg.AddByte(LightLevel);
     msg.AddByte(LightColor);
 }
Ejemplo n.º 8
0
        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;
        }
Ejemplo n.º 9
0
    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>();
        }
Ejemplo n.º 11
0
	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);
	}
Ejemplo n.º 12
0
	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;

		}
	}
Ejemplo n.º 13
0
        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");
 }
Ejemplo n.º 15
0
        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;
        }
Ejemplo n.º 16
0
        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;
        }
Ejemplo n.º 17
0
        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;
        }
Ejemplo n.º 18
0
 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);
 }
Ejemplo n.º 19
0
        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;
        }
Ejemplo n.º 20
0
        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++;
            }
        }
Ejemplo n.º 21
0
        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;
        }
Ejemplo n.º 22
0
    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;

        }
    }
Ejemplo n.º 23
0
        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;
        }
Ejemplo n.º 24
0
    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);
            }
        }
    }
Ejemplo n.º 25
0
        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;
        }
Ejemplo n.º 26
0
 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);
        }
Ejemplo n.º 28
0
        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);
        }
Ejemplo n.º 29
0
        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);
        }
Ejemplo n.º 30
0
        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);
        }
Ejemplo n.º 31
0
 public void SetWerewolf(NetworkMessage message)
 {
     msg.value = message.ReadMessage <StringMessage>().value;
     string[] deltas = msg.value.Split('|');
     gamemng.GetComponent <ClientUI>().SetFangWerewolf(deltas);
 }
Ejemplo n.º 32
0
        protected virtual void OnMessageSended(NetworkMessage message)
        {
            var handler = MessageSent;

            handler?.Invoke(this, message);
        }
Ejemplo n.º 33
0
        protected virtual void OnMessageReceived(NetworkMessage message)
        {
            var handler = MessageReceived;

            handler?.Invoke(this, message);
        }
Ejemplo n.º 34
0
 public bool Handler(ref NetworkMessage message)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 35
0
 public bool Handler(ref NetworkMessage message)
 {
     pParser((PacketSt466)message.PacketTemplate, message.PacketData);
     QueuingService.NetOutQueue.Enqueue(message);
     return(true);
 }
Ejemplo n.º 36
0
        private void OnTeamIdReceived(NetworkMessage netmsg)
        {
            var msg = netmsg.ReadMessage <TeamIdMessage>();

            _allyTeam = msg.TeamId;
        }
Ejemplo n.º 37
0
    //RECEIVE FUNCTIONS

    public void ReceivePlayerName(NetworkMessage message)
    {
        msg.value = message.ReadMessage <StringMessage>().value;
        gamemng.GetComponent <ClientGameController>().UpdateName(msg.value);
    }
Ejemplo n.º 38
0
 void OnClientError(NetworkMessage msg)
 {
     Debug.Log("Error");
 }
Ejemplo n.º 39
0
 public NetworkMessageReaderReadCompletedEventArgs(NetworkMessage netMessage, TcpClient tcpClient)
 {
     this.NetworkMessage = netMessage;
     this.TcpClient      = tcpClient;
 }
Ejemplo n.º 40
0
 public void SetChat(NetworkMessage message)
 {
     msg.value = message.ReadMessage <StringMessage>().value;
     string[] deltas = msg.value.Split('|');
     pymng.GetComponent <ClientChat>().Reader(deltas[0], deltas[1]);
 }
Ejemplo n.º 41
0
 private void PingCommand(NetworkMessage message)
 {
     Send(MessageProtocols.Pong, true);
 }
Ejemplo n.º 42
0
 void OnClientDisconnect(NetworkMessage msg)
 {
     Debug.Log("Disconnected");
 }
Ejemplo n.º 43
0
        private static void OnMPTweaksSet(NetworkMessage rawMsg)
        {
            var msg = rawMsg.ReadMessage <TweaksMessage>();

            MPTweaks.Set(msg.m_settings);
        }
Ejemplo n.º 44
0
 private void EndCommand(NetworkMessage message)
 {
     Terminate();
 }
Ejemplo n.º 45
0
        /// <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());
            }
        }
Ejemplo n.º 46
0
 static void Postfix(NetworkMessage msg)
 {
     MPTweaks.ClientCapabilitiesRemove(msg.conn.connectionId);
 }
Ejemplo n.º 47
0
 public override void ParseFromNetworkMessage(NetworkMessage message)
 {
     Text  = message.ReadString();
     Delay = message.ReadByte();
 }
Ejemplo n.º 48
0
 public void KickedMessageHandler(NetworkMessage netMsg)
 {
     infoPanel.Display("Kicked by Server", "Close", null);
     netMsg.conn.Disconnect();
 }
Ejemplo n.º 49
0
 public override void AppendToNetworkMessage(NetworkMessage message)
 {
     message.Write((byte)ClientPacketType.CloseNpcTrade);
 }
Ejemplo n.º 50
0
 public override void AppendToNetworkMessage(NetworkMessage message)
 {
     message.Write((byte)ServerPacketType.LoginWait);
     message.Write(Text);
     message.Write(Delay);
 }
Ejemplo n.º 51
0
 public void KickedVersionDifferent(NetworkMessage netMsg)
 {
     infoPanel.Display("Version mismatch", "Close", null);
     netMsg.conn.Disconnect();
 }
Ejemplo n.º 52
0
    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;
        }
    }
Ejemplo n.º 53
0
 private void OnError(NetworkMessage netMsg)
 {
     SetUpServer();
     SetUpClient(_port);
 }
Ejemplo n.º 54
0
 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);
 }
Ejemplo n.º 56
0
 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);
 }