private void Connect() { var tcpConfig = new TcpConfig(true, 5000, 5000); client = SimpleWebClient.Create(32000, 500, tcpConfig); client.onConnect += () => Debug.Log($"Connected to Server"); client.onDisconnect += () => Debug.Log($"Disconnected from Server"); client.onData += OnData; client.onError += (exception) => Debug.Log($"Error because of Server, Error:{exception}"); client.Connect(new Uri("ws://localhost:7776")); }
private void Awake() { _moveableReferencer = GetComponent <MoveableReferencer>(); _timerTextController = GetComponent <TimerTextController>(); _scoreboardController = GetComponent <ScoreboardController>(); _audioSource = GetComponent <AudioSource>(); _musicController = GetComponentInChildren <MusicController>(); TcpConfig tcpConfig = new TcpConfig(true, 5000, 45000); _webClient = SimpleWebClient.Create(16 * 1024, 1000, tcpConfig); _webClient.onConnect += WebClientOnonConnect; _webClient.onData += WebClientOnonData; _webClient.onDisconnect += WebClientOnonDisconnect; Builder.ObjectMoved += BuilderOnObjectMoved; Interacter.WrongGuessMade += InteracterOnWrongGuessMade; }
void Start() { _timeSinceLastSend = Time.time; _ghostCars = new Dictionary <ushort, GhostCarBehavior>(); TcpConfig tcpConfig = new TcpConfig(true, 5000, 20000); _ws = SimpleWebClient.Create(16 * 1024, 1000, tcpConfig); _ws.onConnect += delegate { Debug.Log("Client connected"); }; _ws.onData += WsOnonData; _ws.onError += delegate(Exception exception) { Debug.Log("Error: " + exception.Message); }; Connect(true); }
private async Task StartClient() { try { var client = SimpleWebClient.Create(32000, 1000, default); client.Connect(new UriBuilder() { Host = "localhost", Port = 7777, Scheme = "ws" }.Uri); client.onConnect += () => Debug.Log($"Connected to Server"); client.onDisconnect += () => Debug.Log($"Disconnected from Server"); client.onData += (data) => Debug.Log($"Data from Server, {BitConverter.ToString(data.Array, data.Offset, data.Count)}"); client.onError += (exception) => Debug.Log($"Error because of Server, Error:{exception}"); while (true) { client.ProcessMessageQueue(); // ping client.Send(new ArraySegment <byte>(new byte[1] { (byte)(counter++) })); await Task.Yield(); if (token.stop) { break; } } token = null; } catch (Exception e) { Debug.LogException(e); } }