Пример #1
0
        /// <summary>
        /// Tries to get access data for room we want to connect to
        /// </summary>
        /// <param name="roomId"></param>
        private void GetRoomAccess(int roomId)
        {
            logger.Debug($"Getting access to room {roomId}");

            Mst.Client.Rooms.GetAccess(roomId, (access, error) =>
            {
                if (access == null)
                {
                    logger.Error(error);
                    OnAccessDiniedEvent?.Invoke();
                    return;
                }

                // Save gotten room access
                roomServerAccessInfo = access;

                // Let's set the IP before we start connection
                roomServerIp = roomServerAccessInfo.RoomIp;

                // Let's set the port before we start connection
                roomServerPort = roomServerAccessInfo.RoomPort;

                logger.Debug($"Access to room {roomId} received");
                logger.Debug(access);
                logger.Debug("Connecting to room server...");

                // Start client connection
                roomServerConnection.UseSsl = MstApplicationConfig.Instance.UseSecure || Mst.Args.UseSecure;
                roomServerConnection.Connect(roomServerIp, roomServerPort);

                // Wait a result of client connection
                roomServerConnection.WaitForConnection((clientSocket) =>
                {
                    if (!clientSocket.IsConnected)
                    {
                        logger.Error("Connection attempts to room server timed out");
                        return;
                    }
                }, 4f);
            });
        }
Пример #2
0
 /// <summary>
 /// This method triggers the <see cref="OnAccessReceivedEvent"/> event. Call this,
 /// if you made some custom functionality to get access to rooms
 /// </summary>
 /// <param name="access"></param>
 public void TriggerAccessReceivedEvent(RoomAccessPacket access)
 {
     LastReceivedAccess = access;
     OnAccessReceivedEvent?.Invoke(access);
 }