예제 #1
0
 /// <summary>
 /// Sends a request to the server to join a room
 /// <para>
 /// use <b>public override void OnRoomJoin</b>  to get the server response
 /// </para>
 /// </summary>
 /// <param name="roomId">Id of the room intended to join</param>
 /// <param name="playerAvatar">(integer value) Avatar Index from EdgeManager Spawn Prefabs</param>
 /// <param name="playerTags">Dictionary<string,string> custom data associated with the player</param>
 public static void JoinRoom(string roomId, string playerName, int playerAvatar, Dictionary <string, string> playerTags = null)
 {
     if (gameSession.roomId == "")
     {
         Hashtable playertagsHashtable;
         if (playerTags != null)
         {
             playertagsHashtable = Tag.DictionaryToHashtable(playerTags);
         }
         else
         {
             playertagsHashtable = null;
         }
         JoinRoomRequest joinRoomRequest = new JoinRoomRequest(roomId, playerName, playerAvatar, playertagsHashtable);
         wsClient.Send(Messaging <JoinRoomRequest> .Serialize(joinRoomRequest));
     }
     else
     {
         if (gameSession.roomId == roomId)
         {
             Debug.LogError("EdgeMultiplay : Player is already a member in this room");
         }
         else
         {
             Debug.LogError("EdgeMultiplay : Player is already a member in another room");
         }
     }
 }
예제 #2
0
 /// <summary>
 /// Sends a request to the server to create a room
 /// <para>
 /// use <b>public override void OnRoomCreated</b>  to get the server response
 /// </para>
 /// </summary>
 /// <param name="playerName">player name to be assigned to player</param>
 /// <param name="playerAvatar">(integer value) Avatar Index from EdgeManager Spawn Prefabs</param>
 /// <param name="maxPlayersPerRoom">The maximum players allowed in the room</param>
 /// <param name="playerTags">Dictionary<string,string> custom data associated with the player</param>
 public static void CreateRoom(string playerName, int playerAvatar, int maxPlayersPerRoom, Dictionary <string, string> playerTags = null)
 {
     if (maxPlayersPerRoom < 2)
     {
         Debug.LogError("EdgeMultiplay : maxPlayersPerRoom must be greater than 1");
         return;
     }
     // Assure Player is not already a member of another room
     if (gameSession.roomId == "")
     {
         Hashtable playertagsHashtable;
         if (playerTags != null)
         {
             playertagsHashtable = Tag.DictionaryToHashtable(playerTags);
         }
         else
         {
             playertagsHashtable = null;
         }
         CreateRoomRequest createRoomRequest = new CreateRoomRequest(playerName, playerAvatar, maxPlayersPerRoom, playertagsHashtable);
         wsClient.Send(Messaging <CreateRoomRequest> .Serialize(createRoomRequest));
     }
     else
     {
         Debug.LogError("EdgeMultiplay : Player is already a member in another room");
     }
 }
예제 #3
0
        /// <summary>
        /// Sends Join Or Create Room request to the server, the server will try to match a player with any available room
        /// if the server didn't find an available room, the server will create a room for the player
        /// <para>
        /// use <b>public override void OnRoomCreated</b> or <b>public override void OnRoomJoin</b> to get the server response
        /// </para>
        /// </summary>
        /// <param name="playerName"> player name to be assigned to player</param>
        /// <param name="playerAvatar">(integer value) Avatar Index from EdgeManager Spawn Prefabs</param>
        /// <param name="maxPlayersPerRoom">In case of room creation, the maximum players allowed in the room</param>
        /// <param name="playerTags">Dictionary<string,string> custom data associated with the player</param>
        public static void JoinOrCreateRoom(string playerName, int playerAvatar, int maxPlayersPerRoom, Dictionary <string, string> playerTags = null)
        {
            if (maxPlayersPerRoom < 2)
            {
                Debug.LogError("EdgeMultiplay : maxPlayersPerRoom must be greater than 1");
                return;
            }
            Hashtable playertagsHashtable;

            if (playerTags != null)
            {
                playertagsHashtable = Tag.DictionaryToHashtable(playerTags);
            }
            else
            {
                playertagsHashtable = null;
            }
            JoinOrCreateRoomRequest createOrJoinRoomRequest = new JoinOrCreateRoomRequest(playerName, playerAvatar, maxPlayersPerRoom, playertagsHashtable);

            wsClient.Send(Messaging <JoinOrCreateRoomRequest> .Serialize(createOrJoinRoomRequest));
        }
예제 #4
0
 public void SendGamePlayEvent(GamePlayEvent mobiledgexEvent)
 {
     mobiledgexEvent.roomId   = gameSession.roomId;
     mobiledgexEvent.senderId = gameSession.playerId;
     wsClient.Send(Messaging <GamePlayEvent> .Serialize(mobiledgexEvent));
 }
예제 #5
0
        /// <summary>
        /// Exit the current room you are in
        /// </summary>
        public static void ExitRoom()
        {
            ExitRoomRequest exitRoomRequest = new ExitRoomRequest();

            wsClient.Send(Messaging <ExitRoomRequest> .Serialize(exitRoomRequest));
        }
예제 #6
0
        /// <summary>
        /// Sends a request to the server to get a full list of rooms on the servers
        /// <para>
        /// use <b>public override void OnRoomsListReceived</b> to get the server response
        /// </para>
        /// </summary>
        public static void GetAvailableRooms()
        {
            GetAvailableRoomsRequest getAvailableRoomsRequest = new GetAvailableRoomsRequest();

            wsClient.Send(Messaging <GetAvailableRoomsRequest> .Serialize(getAvailableRoomsRequest));
        }