Пример #1
0
        /// <summary>
        /// Connects to a game based on Player.IO as the given user.
        /// </summary>
        /// <param name="gameId">The ID of the game you wish to connect to. This value can be found in the admin panel.</param>
        /// <param name="connectionId">The ID of the connection, as given in the settings section of the admin panel. 'public' should be used as the default.</param>
        /// <param name="userId">The ID of the user you wish to authenticate.</param>
        /// <param name="auth">If the connection identified by ConnectionIdentifier only accepts authenticated requests: The auth value generated based on 'userId'.
        /// You can generate an auth value using the CalcAuth() method.</param>
        /// <returns>A new instance of Client if logging in was successful.</returns>
        public static Client Connect(string gameId, string connectionId, string userId, string auth)
        {
            var connectArg = new ConnectArgs
            {
                GameId       = gameId,
                ConnectionId = connectionId,
                UserId       = userId,
                Auth         = auth
            };
            var connectOutput = Channel.Request <ConnectArgs, ConnectOutput, PlayerIOError>(10, connectArg);

            return(new Client(Channel, connectOutput.Token, connectOutput.UserId));
        }
Пример #2
0
        /// <summary>
        /// Creates a multiplayer room (if it doesn't exists already), and joins it.
        /// </summary>
        /// <param name="roomId">The ID of the room you wish to (create and then) join.</param>
        /// <param name="serverType">If the room doesn't exists: The name of the room type you wish to run the room as. This value should match one of the 'RoomType(...)' attributes of your uploaded code. A room type of 'bounce' is always available.</param>
        /// <param name="visible">If the room doesn't exists: Determines (upon creation) if the room should be visible when listing rooms with GetRooms.</param>
        /// <param name="roomData">If the room doesn't exists: The data to initialize the room with (upon creation).</param>
        /// <param name="joinData">Data to send to the room with additional information about the join.</param>
        public Connection CreateJoinRoom(string roomId, string serverType, bool visible = true, Dictionary <string, string> roomData = null, Dictionary <string, string> joinData = null)
        {
            var createJoinRoomArg = new CreateJoinRoomArgs
            {
                RoomId     = roomId,
                ServerType = serverType,
                Visible    = visible,
                RoomData   = Converter.Convert(roomData),
                JoinData   = Converter.Convert(joinData),
                IsDevRoom  = DevelopmentServer != null
            };
            var createJoinRoomOutput = _channel.Request <CreateJoinRoomArgs, CreateJoinRoomOutput, PlayerIOError>(27, createJoinRoomArg);
            var serverEndpoint       = DevelopmentServer ?? Converter.Convert(createJoinRoomOutput.Endpoints[0]);

            return(new Connection(serverEndpoint, createJoinRoomOutput.JoinKey));
        }
Пример #3
0
        public DatabaseObject LoadMyPlayerObject()
        {
            var loadMyPlayerObjectOutput = _channel.Request <NoArgsOrOutput, LoadMyPlayerObjectOutput, PlayerIOError>(103, new NoArgsOrOutput());

            loadMyPlayerObjectOutput.PlayerObject.Table = PlayerObjectsTableName;
            return(loadMyPlayerObjectOutput.PlayerObject);
        }
Пример #4
0
        /// <summary>
        /// Connects to a game based on Player.IO as a simple user.
        /// </summary>
        /// <param name="gameId">The ID of the game you wish to connect to. This value can be found in the admin panel.</param>
        /// <param name="usernameOrEmail">The username or e-mail address of the user you wish to authenticate.</param>
        /// <param name="password">The password of the user you wish to authenticate.</param>
        public Client SimpleConnect(string gameId, string usernameOrEmail, string password)
        {
            var simpleConnectArgs = new SimpleConnectArgs
            {
                GameId          = gameId,
                UsernameOrEmail = usernameOrEmail,
                Password        = password
            };
            var simpleConnectOutput =
                _channel.Request <SimpleConnectArgs, ConnectOutput, PlayerIOError>(400,
                                                                                   simpleConnectArgs);

            return(new Client(_channel, simpleConnectOutput.Token, simpleConnectOutput.UserId));
        }