/// <summary> /// Start connection to master /// </summary> private void ConnectToMaster() { // Start room connection to master if (!masterConnection.IsConnected) { masterConnection.Connect(masterIp, masterPort); } // Wait a result of client connection masterConnection.WaitForConnection((clientSocket) => { if (!clientSocket.IsConnected) { logger.Error("Failed to connect room server to master server"); } else { logger.Info("Room server is successfuly connected to master server"); // Start the server on next frame MsfTimer.WaitForEndOfFrame(() => { StartServer(roomOptions.RoomIp, roomOptions.RoomPort); }); } }, 4f); }
public void Connect() { if (!_client.Connected) { _client.Connect(); OnConnected?.Invoke(this); } }
public void Connect(string oauth) { BotLogger.LogDebug("[ >>Connecting! ]"); Socket.Connect(); SendOauth(oauth); SendToIRC(IRCSymbols.FormatUsername(Username)); SendToIRC(IRCSymbols.FormatJoin(DefaultChannel)); RequestTwitchMembershipStateEvents(); this.Running = true; ReceivingThread.Start(); }
public void StartClient(string address, ushort port, INetworkMediator netMediator) { networkMediator = netMediator; _socket.Connect(address, port); CancellationSource = new CancellationTokenSource(); Task.Run(ReadNetwork, CancellationSource.Token); BMSByte buffer = new BMSByte(); buffer.Append(new byte[] { 1 }); _socket.Send(_socket.EndPoint, buffer); }
/// <summary> /// Starting connection to master server as client to be able to register room later after successful connection /// </summary> private void ConnectToMaster() { // Start client connection if (!masterConnection.IsConnected) { masterConnection.UseSsl = MstApplicationConfig.Instance.UseSecure || Mst.Args.UseSecure; masterConnection.Connect(masterIP, masterPort); } // Wait a result of client connection masterConnection.WaitForConnection((clientSocket) => { if (!clientSocket.IsConnected) { logger.Error("Failed to connect room client to master server"); } else { logger.Info($"Successfully connected to master {masterConnection.ConnectionIp}:{masterConnection.ConnectionPort}"); // For the test purpose only if (IsInTestMode()) { if (signInAsGuest) { // Sign in client as guest Mst.Client.Auth.SignInAsGuest(SignInCallback); } else { // Sign in client using credentials Mst.Client.Auth.SignInWithLoginAndPassword(username, password, SignInCallback); } } else { // If we have option with room id // this approach can be used when you have come to this scene from another one. // Set this option before this room client controller is connected to master server if (Mst.Options.Has(MstDictKeys.ROOM_ID)) { // Let's try to get access data for room we want to connect to GetRoomAccess(Mst.Options.AsInt(MstDictKeys.ROOM_ID)); } else { logger.Error($"You have no room id in this options: {Mst.Options}"); } } } }, 5f); }
private void StartClient() { if (UseWs) { _client = new ClientSocketWs(); } else { _client = new ClientSocketUnet(); } _client.Connected += Connected; _client.Disconnected += Disconnected; _client.SetHandler(new PacketHandler(_messageOpCode, HandleMessage)); Debug.Log("Client: Trying to connect to " + ServerIpAddress + ":" + Port); _client.Connect(ServerIpAddress, Port); }
/// <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); }); }
public void Connect() { _udpClient.Connect(); }
//private void ExceptionHandler(Task task) //{ // log4j.Info("ExceptionHandler", task.Exception); //} public void Connect() { _client.Connect(); }
public void Connect() { _clientSocket.Connect(); }