Esempio n. 1
0
 public void SendJoinMessage()
 {
     JoinMessage jm = new JoinMessage();
     jm.name = nameT.text;
     jm.team = playerChoice;
     nm.client.Send(Msgs.clientJoinMsg, jm);
 }
Esempio n. 2
0
    private void JoinFirstTime(NetworkConnection connection, Player newPlayer, JoinMessage joinMessage)
    {
        string reqPassword = Config.Instance.password;

        if (reqPassword.Length != 0 && joinMessage.password.Equals(reqPassword) == false)
        {
            DelayedDisconnect(connection, DisconnectMessage.Type.PasswordWrong);

            Destroy(newPlayer);
            return;
        }

        int?index = GetPlayerIndex(connection.connectionId);

        if (index == null)
        {
            DelayedDisconnect(connection, DisconnectMessage.Type.ServerFull);

            Destroy(newPlayer);
            return;
        }
        newPlayer.playerIndex = index.Value;

        NetworkServer.AddPlayerForConnection(connection, newPlayer.gameObject);
        newPlayer.entityName = joinMessage.name;
    }
Esempio n. 3
0
        public void JoinMessageTokens()
        {
            var channel     = "#chan";
            var joinMessage = new JoinMessage(channel);

            Assert.Equal($"JOIN {channel}", joinMessage.ToString());
        }
Esempio n. 4
0
    /// <summary>
    /// JoinMessage is sent by clients when a player joins for the first time or
    /// when a player wants to change their roll.
    /// </summary>
    /// <param name="connection">The client who sent the message.</param>
    /// <param name="joinMessage">The message.</param>
    private void OnJoinMessage(NetworkConnection connection, JoinMessage joinMessage)
    {
        Player oldPlayer = PlayersDict.Instance.GetPlayerWithUniqueIdentifier(joinMessage.uniqueIdentifier);

        // Was the player connected to the server before?
        if (oldPlayer != null)
        {
            // Is the player still connected?
            if (connection.identity?.gameObject == oldPlayer.gameObject)
            {
                JoinReplaceCharacter(connection, JoinCreateNewPlayer(connection, joinMessage), joinMessage);
                return;
            }

            // Player is reconnecting
            JoinReconnect(connection, oldPlayer);
            return;
        }

        // Is the game already in progress?
        if (RegionDict.Instance.Region != Region.Lobby)
        {
            DelayedDisconnect(connection, DisconnectMessage.Type.JoinedGameInProgress);
            return;
        }

        // Player joined for the first time and we are in the lobby scene.
        Player newPlayer = JoinCreateNewPlayer(connection, joinMessage);

        JoinFirstTime(connection, newPlayer, joinMessage);
        RAGMatchmaker.Instance.UpdatePlayerCount(PlayersDict.Instance.Players.Count);
    }
        void AddCommand_()
        {
            JoinMessage msg = new JoinMessage();

            msg.PlayerName = PlayerName;
            Connection.Send(msg);
        }
Esempio n. 6
0
        //abuse
        public void OnJoinGame(NetworkConnection conn, JoinMessage Join)
        {
            NetPlayer NP = Instantiate(playerPrefab).GetComponent <NetPlayer>();

            NetworkServer.AddPlayerForConnection(conn, NP.gameObject);

            PlayerBrain PB = Instantiate(GamePlayer);

            NetworkServer.Spawn(PB.gameObject, conn);

            for (int i = 0; i < 25; i++)
            {
                ItemBox IB = Instantiate(ItemBox);
                NetworkServer.Spawn(IB.gameObject);
                IB.Randomize();
            }
            for (int i = 0; i < 5; i++)
            {
                PlatBrain PlB = Instantiate(PlatGuy);
                PlB.transform.position = new Vector3(300, 300, 0) * Random.insideUnitCircle;
                NetworkServer.Spawn(PlB.gameObject);
                PlB.Die();
            }

            //Players.Add(NP.netId, NP);
            //PlayerBrains.Add(NP.netId, PB);

            JoinedMessage joined = new JoinedMessage();

            //Debug.Log(NP.netId+"|"+PB.netId);
            joined.id     = NP.netId;
            joined.Player = PB.netId;
            NetworkServer.SendToAll(joined);
        }
Esempio n. 7
0
        public void Invite(String[] channelNameAndUserNames)
        {
            if (channelNameAndUserNames.Length == 1)
            {
                Console.NotifyMessage("エラー: ユーザが指定されていません。");
                return;
            }

            if (!Session.Groups.ContainsKey(channelNameAndUserNames[0]))
            {
                Console.NotifyMessage("エラー: 指定されたグループは存在しません。");
                return;
            }

            for (var i = 1; i < channelNameAndUserNames.Length; i++)
            {
                Group  group    = CurrentSession.Groups[channelNameAndUserNames[0]];
                String userName = channelNameAndUserNames[i];
                if (!group.Exists(userName) && (String.Compare(userName, CurrentSession.Nick, true) != 0))
                {
                    group.Add(userName);
                    if (group.IsJoined)
                    {
                        JoinMessage joinMsg = new JoinMessage(channelNameAndUserNames[0], "")
                        {
                            SenderHost = "twitter@" + Server.ServerName,
                            SenderNick = userName
                        };
                        CurrentSession.Send(joinMsg);
                    }
                }
            }

            CurrentSession.SaveGroups();
        }
Esempio n. 8
0
        private void ProcessDispatch(EventPayload response)
        {
            if (response.Command != Command.Dispatch)
            {
                return;
            }
            if (!response.Event.HasValue)
            {
                return;
            }

            switch (response.Event.Value)
            {
            //We are to join the server
            case ServerEvent.ActivitySpectate:
                SpectateMessage spectate = response.GetObject <SpectateMessage>();
                EnqueueMessage(spectate);
                break;

            case ServerEvent.ActivityJoin:
                JoinMessage join = response.GetObject <JoinMessage>();
                EnqueueMessage(join);
                break;

            case ServerEvent.ActivityJoinRequest:
                JoinRequestMessage request = response.GetObject <JoinRequestMessage>();
                EnqueueMessage(request);
                break;

            //Unkown dispatch event received. We should just ignore it.
            default:
                Logger.Warning("Ignoring {0}", response.Event.Value);
                break;
            }
        }
    private JoinMessage MakeJoinMessage()
    {
        var msg = new JoinMessage();

        msg.playerName      = PlayerSave.GetPlayerName();
        msg.selectHead      = GameInstance.GetAvailableHead(PlayerSave.GetHead()).GetId();
        msg.selectCharacter = GameInstance.GetAvailableCharacter(PlayerSave.GetCharacter()).GetId();
        // Weapons
        var savedWeapons  = PlayerSave.GetWeapons();
        var selectWeapons = "";

        foreach (var savedWeapon in savedWeapons)
        {
            if (!string.IsNullOrEmpty(selectWeapons))
            {
                selectWeapons += "|";
            }
            var data = GameInstance.GetAvailableWeapon(savedWeapon.Value);
            if (data != null)
            {
                selectWeapons += data.GetId();
            }
        }
        msg.selectWeapons = selectWeapons;
        return(msg);
    }
Esempio n. 10
0
        /// <summary>
        /// Get messages to send in response to a JoinMessage
        /// </summary>
        /// <param name="uid"> The uid of the player </param>
        /// <param name="joinMessage"></param>
        /// <returns> List of messages to be sent </returns>
        public MessagePackets HandleJoin(string uid, JoinMessage joinMessage)
        {
            lock (this)
            {
                if (PlayerGameTypeMap.ContainsKey(uid))
                {
                    PlayerGameNameMap.Add(uid, joinMessage.GameName);

                    string gameType = PlayerGameTypeMap[uid];
                    if (GameNameMap[gameType].ContainsKey(joinMessage.GameName))
                    {
                        // The game exists, so join it
                        return(GameNameMap[gameType][joinMessage.GameName].HandleJoin(uid, joinMessage));
                    }
                    else
                    {
                        MessagePackets messages = new MessagePackets();

                        // The game doesn't exist, so make a new one and join it
                        GameManager gm = (GameManager)Activator.CreateInstance(GameManagerMap[gameType]);
                        GameNameMap[gameType].Add(joinMessage.GameName, gm);
                        messages.Add(gm.HandleJoin(uid, joinMessage));

                        // Push available games update
                        messages.Add(GetAvailableGamesMessage(gameType));

                        return(messages);
                    }
                }
                else
                {
                    throw new Exception("Game type not known for player " + uid);
                }
            }
        }
Esempio n. 11
0
        private IUserInfo GetJoiningUserInfo(IConnection connection, JoinMessage join)
        {
            if (!Manager.GetIsConnected(connection))
            {
                connection.SendAsync(new JoinResultMessage(LoginResultState.FailedNotConnected, null));
                return(null);
            }

            IUserInfo info = this.Manager.GetUser(connection);

            if (info == null)
            {
                if (!this.context.Settings.AllowGuestLogins)
                {
                    connection.SendAsync(new JoinResultMessage(LoginResultState.FailedUsername, null));
                    return(null);
                }

                LoginResult r = this.context.UserProvider.Login(join.Nickname, null);
                if (!r.Succeeded)
                {
                    connection.SendAsync(new JoinResultMessage(r.ResultState, null));
                    return(null);
                }

                info = new UserInfo(join.Nickname, join.Phonetic, join.Nickname, r.UserId, this.context.ChannelsProvider.DefaultChannel.ChannelId, false);
            }
            else
            {
                info = new UserInfo(join.Nickname, join.Phonetic, info);
            }

            return(info);
        }
Esempio n. 12
0
        public void TestHandleJoin()
        {
            string         uid      = "uid";
            string         userName = "******";
            string         gameName = "game";
            MessagePackets messages = JoinGame(uid, userName, gameName);

            List <Player> players = gm.GetPlayers();

            Assert.AreEqual(players.Count, 1);
            Assert.AreEqual(players.Last().Name, userName);
            Assert.AreEqual(players.Last().Uid, uid);

            Assert.IsTrue(Utils.VerifyMessagePackets(messages, typeof(JoinResponse), typeof(JoinMessage)));

            JoinResponse jr = (JoinResponse)messages.Messages[0].Message;

            Assert.AreEqual(messages.Messages[0].SendTo.Count(), 1);
            Assert.AreEqual(messages.Messages[0].SendTo.Single(), uid);
            Assert.AreEqual(jr.UserName, userName);
            Assert.AreEqual(jr.ErrorMessage, null);
            Assert.IsTrue(jr.Success);

            JoinMessage jm = (JoinMessage)messages.Messages[1].Message;

            Assert.AreEqual(messages.Messages[1].SendTo.Count(), 1);
            Assert.AreEqual(messages.Messages[1].SendTo.Single(), uid);
            Assert.AreEqual(jm.UserName, userName);
            Assert.AreEqual(jm.GameName, gameName);
            Assert.AreEqual(jm.Order, 0);
        }
Esempio n. 13
0
        public void GetJoinMessageTests()
        {
            var joinMessageString   = "S:P0;0,0;0#";
            var joinMessage         = MessageFactory.GetMessage(joinMessageString);
            var joinMessageExpected =
                new JoinMessage(new[] { new JoinMessage.TankDetails(0, new Point(0, 0), Direction.North) });

            Assert.NotNull(joinMessage);
            Assert.IsInstanceOf <JoinMessage>(joinMessage);
            Assert.AreEqual(joinMessageExpected, joinMessage);

            var joinMessageCast = joinMessage as JoinMessage;

            Assume.That(joinMessageCast, Is.Not.Null);

            Assert.AreEqual(new Point(0, 0), joinMessageCast?.TanksDetails?.ToArray()[0].Location);
            Assert.AreEqual(Direction.North, joinMessageCast?.TanksDetails?.ToArray()[0].FacingDirection);
            Assert.AreEqual(0, joinMessageCast?.TanksDetails?.ToArray()[0].PlayerNumber);

            var joinMessageUnexpected =
                new JoinMessage(new[] { new JoinMessage.TankDetails(0, new Point(1, 1), Direction.North) });

            Assert.AreNotEqual(joinMessageUnexpected, joinMessageCast);
            Assert.True(joinMessageCast != joinMessageUnexpected);

            Assert.True(joinMessageExpected.GetHashCode() == joinMessageCast?.GetHashCode());
            Assert.False(joinMessageExpected.GetHashCode() == joinMessageUnexpected.GetHashCode());
        }
Esempio n. 14
0
        public void JoinMessageWithKeyTokens()
        {
            var channel     = "#chan";
            var key         = "12345";
            var joinMessage = new JoinMessage(channel, key);

            Assert.Equal($"JOIN {channel} {key}", joinMessage.ToString());
        }
Esempio n. 15
0
 /// <summary>
 /// Joins the specified channel.
 /// </summary>
 /// <param name="channelName">The channel to join.</param>
 public void JoinChannel(string channelName)
 {
     if (this.owner.Marshal != null)
     {
         JoinMessage message = new JoinMessage(channelName);
         this.owner.Marshal.Send(this.owner, message);
     }
 }
Esempio n. 16
0
 private static void OnJoin(object sender, JoinMessage args)
 {
     Process.Start(new ProcessStartInfo
     {
         FileName        = args.Secret,
         UseShellExecute = true
     });
 }
Esempio n. 17
0
        public override void OnClientConnect(NetworkConnection conn)
        {
            base.OnClientConnect(conn);
            JoinMessage Join = new JoinMessage();

            Join.Name  = PlayerClient.PC.CP.N.text;
            Join.Color = PlayerClient.PC.CP.C;
            conn.Send(Join);
        }
Esempio n. 18
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="message">Join message.</param>
 public GameJoinRequestedEventArgs(JoinMessage message)
 {
     Message = new JoinMessage
     {
         JoiningUser = message.JoiningUser,
         Request     = message.Request,
         UID         = message.UID
     };
 }
        public static void HandleJoinMessage(SimpleClient client, JoinMessage message)
        {
            Character character = client.Account.Characters.FirstOrDefault(x => x.Id == message.characterId);

            if (character == null)
            {
                client.Disconnect();
                return;
            }

            client.Character        = character;
            client.Character.Client = client;

            Map map = WorldManager.Instance.GetMapById(character.Record.SceneId);

            if (map == null)
            {
                client.Disconnect();
                return;
            }

            client.Character.Position = new ObjectPosition(character.Record.X, character.Record.Y, character.Record.Z);

            map.Enter(client.Character);

            SendJoinRightMessage(client, message.characterId, character.Position.Map.SceneId, character.Position.X, character.Position.Y, character.Position.Z, false, 0);//Send all players in the map
            var stats = StatsFields.LoadInertieData();

            SendSnapshotMessage(client, new Snapshot[] { new SetStateVerSnapshot(1),
                                                         new UpdateServerTimeSnapshot(DateTime.UtcNow.GetUnixTimeStamp()),
                                                         new AddObjectSnapshot(client.Character.GetObjectType(true)),
                                                         new AddObjectSnapshot(new MonsterObjectType(ObjectTypeEnum.OT_MOB, (uint)client.GetHashCode(),
                                                                                                     20, 0xFFFFFFFF, 609, 300, 600, 0, 0, 100, "Nuan",
                                                                                                     stats.Count, stats.Keys.Select(x => (ushort)x).ToArray(),
                                                                                                     stats.Values.Select(x => x.Total).ToArray(), 0, new byte[0], new int[0], new int[0], 1,
                                                                                                     false, 255, 0, 0, 0, 0, new uint[0], 0, true, true, false, 0, 0, 2, -1, 0)) });
            foreach (var attribute in client.Character.Stats.Fields)
            {
                SendSnapshotMessage(client, new []
                {
                    new SetValueObjectSnapshot((uint)client.Character.GetHashCode(), (short)attribute.Key, attribute.Value.Total),
                });
            }
            List <Snapshot> spawnOtherObjects = new List <Snapshot>();

            foreach (var @object in map.Objects.Where(x => x != character))
            {
                spawnOtherObjects.Add(new AddObjectSnapshot(@object.GetObjectType()));
            }
            SendSnapshotMessage(client, spawnOtherObjects.ToArray());

            //foreach (var stats in client.Character.Stats.Fields)
            //{
            //    SendSnapshotMessage(client, new Snapshot[] { new SetValueObjectSnapshot((uint)client.Character.GetHashCode(), (short)stats.Key, (int)stats.Value.Total) });
            //}
        }
Esempio n. 20
0
        public void Join(string name)
        {
            Console.WriteLine("Join as '{0}'", name);

            var message = new JoinMessage {
                Name = name
            };

            SendMessage(message.ToJson());
        }
 /// <summary>
 /// Create a new ZreMsgOriginal
 /// </summary>
 public ZreMsgOriginal()
 {
     Hello   = new HelloMessage();
     Whisper = new WhisperMessage();
     Shout   = new ShoutMessage();
     Join    = new JoinMessage();
     Leave   = new LeaveMessage();
     Ping    = new PingMessage();
     PingOk  = new PingOkMessage();
 }
Esempio n. 22
0
 private void OnJoin(object sender, JoinMessage args)
 {
     presence.Party.Size++;
     presence.Secrets.JoinSecret = args.Secret;
     MessageBox.Show("OnJoin: " + args.Secret);
     _control.StopRadio();
     _control.RefreshSource(true);
     Utils.SaveSetting("spyserver.uri", args.Secret);
     _control.StartRadio();
 }
Esempio n. 23
0
        private void HandleLeave(LeaveMessage msg)
        {
            _tcpServer = new TCPServer(
                IPAddress.Parse(_config.TCPServerAddress),
                Int32.Parse(_config.TCPServerPort));
            _tcpServer.OnReceiveMessage += _tcpServer_OnReceiveMessage;

            _joinMsg  = null;
            _leaveMsg = msg;
            _elector.Elect();
        }
Esempio n. 24
0
        private void JoinParty(object sender, JoinMessage args)
        {
            object lobby = Program.sdk.Networking.GetLobbyFromInviteCode(args.Secret);

            if (lobby == null)
            {
                return;
            }

            Game1.ExitToTitle(() => { TitleMenu.subMenu = new FarmhandMenu(Program.sdk.Networking.CreateClient(lobby)); });
        }
Esempio n. 25
0
    public override void OnClientConnect(NetworkConnection conn)
    {
        base.OnClientConnect(conn);

        JoinMessage joinMessage = JoinMessage.GetDefault();

        conn.Send(joinMessage);

        ExpectingDisconnect     = false;
        expectingDisconnectType = DisconnectMessage.Type.Unknown;
    }
Esempio n. 26
0
        private void SendJoin()
        {
            var joinMsg = new JoinMessage()
            {
                SourceID      = _config.ID,
                DestinationID = Constants.NULL_DESTINATION,
                Address       = _config.TCPServerAddress,
                Port          = _config.TCPServerPort
            };

            SendMessage(joinMsg, _group);
        }
Esempio n. 27
0
    private Player JoinCreateNewPlayer(NetworkConnection connection, JoinMessage joinMessage)
    {
        Player newPlayer = Instantiate(CharacterDict.Instance.GetPlayerForType(joinMessage.characterType));

        newPlayer.SmoothSync.setPosition(
            RandomUtil.Element(startPositions).position,
            true
            );
        newPlayer.playerId         = connection.connectionId;
        newPlayer.uniqueIdentifier = joinMessage.uniqueIdentifier;
        return(newPlayer);
    }
Esempio n. 28
0
    public void OnGameJoined(JObject jsonObject)
    {
        Debug.Log("Game joined: " + jsonObject);
        JoinMessage message       = jsonObject.ToObject <JoinMessage>();
        int         serverVersion = message.serverVersion;

        if (serverVersion != GameClient.Instance.clientVersion)
        {
            Debug.LogWarning("Client and server version mismatch: " + GameClient.Instance.clientVersion + " != " + serverVersion);
        }
        GameClient.Instance.sceneTransition.TransitionIn();
        GameManager.Instance.HandleJoin(message);
    }
Esempio n. 29
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        if (collision.TryGetComponent(out Player player) && player.isLocalPlayer)
        {
            if (toSwitchTo == Config.Instance.SelectedPlayerType)
            {
                return;
            }

            JoinMessage joinMessage = JoinMessage.GetDefault();
            joinMessage.characterType = toSwitchTo;
            NetworkClient.Send(joinMessage);
        }
    }
Esempio n. 30
0
        void OnJoin(object sender, JoinMessage args)
        {
            if (currentState != DiscordState.InMenu)
            {
                return;
            }

            var server = args.Secret.Split('|');

            Game.RunAfterTick(() =>
            {
                Game.RemoteDirectConnect(new ConnectionTarget(server[0], int.Parse(server[1])));
            });
        }
Esempio n. 31
0
    public void HandleJoin(JoinMessage message)
    {
        Debug.Log("Join message received: " + message);
        int serverVersion = message.serverVersion;

        if (serverVersion != GameClient.Instance.clientVersion)
        {
            Debug.LogWarning("Client and server version mismatch: " + GameClient.Instance.clientVersion + " != " + serverVersion);
        }

        GameClient.Instance.sceneTransition.Message    = "Engage!";
        GameClient.Instance.sceneTransition.startDelay = 0;
        GameClient.Instance.sceneTransition.TransitionIn();
    }
		public async void Join (Guid multiplayerChallengeId)
		{
			try {
				var joinMsg = new JoinMessage (userName, multiplayerChallengeId);
				string message = JsonConvert.SerializeObject (joinMsg, jsonSerializerSettings);
				await connectionService.Send (message);
				Debug.WriteLine ("sent join message");
			} catch (Exception e) {
				Debug.WriteLine ("Joining failed: " + e.Message);
			}
		}
Esempio n. 33
0
 /// <summary>
 /// Joins the specified channel.
 /// </summary>
 /// <param name="channelName">The channel to join.</param>
 public void JoinChannel(string channelName)
 {
     if (this.owner.Marshal != null)
     {
         JoinMessage message = new JoinMessage(channelName);
         this.owner.Marshal.Send(this.owner, message);
     }
 }
        public async Task Join()
        {
            var joinMsg = new JoinMessage();
            joinMsg.challengeId = challengeId;
            joinMsg.userName = userName;
            var joinMessage = new MessageFrame("join", joinMsg);

            string message = JsonConvert.SerializeObject(joinMessage);
            await connection.SendAsync(message);

            Debug.WriteLine("sent join message");
        }
Esempio n. 35
0
		/// <summary>
		/// Create a new ZreMsg
		/// </summary>
		public ZreMsg()
		{    
			Hello = new HelloMessage();
			Whisper = new WhisperMessage();
			Shout = new ShoutMessage();
			Join = new JoinMessage();
			Leave = new LeaveMessage();
			Ping = new PingMessage();
			PingOk = new PingOkMessage();
		}			
 void AddCommand_()
 {
     JoinMessage msg = new JoinMessage();
       msg.PlayerName = PlayerName;
       Connection.Send(msg);
 }