public void StartClient(TMPro.TextMeshProUGUI TMP) { client = new Telepathy.Client(); if (string.IsNullOrEmpty(TMP.text)) { client.Connect(serverIP, port); } else { client.Connect(TMP.text, port); } }
void OnGUI() { // client GUI.enabled = !client.Connected; if (GUI.Button(new Rect(0, 0, 120, 20), "Connect Client")) { client.Connect("localhost", 1337); } GUI.enabled = client.Connected; if (GUI.Button(new Rect(130, 0, 120, 20), "Disconnect Client")) { client.Disconnect(); } // server GUI.enabled = !server.Active; if (GUI.Button(new Rect(0, 25, 120, 20), "Start Server")) { server.Start(1337); } GUI.enabled = server.Active; if (GUI.Button(new Rect(130, 25, 120, 20), "Stop Server")) { server.Stop(); } GUI.enabled = true; }
void OnGUI() { ServerIP = GUI.TextField(new Rect(0, 25, 240, 20), ServerIP, 25); // server GUI.enabled = !client.Connected; if (GUI.Button(new Rect(0, 50, 120, 20), "Join localhost")) { client.Connect(ServerIP, 1337); } GUI.enabled = client.Connected; if (GUI.Button(new Rect(130, 50, 120, 20), "Disconnect")) { client.Disconnect(); for (int i = 0; i < Players.Count; i++) { Destroy(Players[i].PlayerOBJ); } Players.Clear(); } GUI.enabled = true; }
private void connect_Click(object sender, EventArgs e) { client.Connect(ipTB.Text, 1337); // ip address serverConnect(); System.Threading.Thread.Sleep(1000); }
void OnGUI() { // client GUI.enabled = !client.Connected; if (GUI.Button(new Rect(0, 0, 120, 20), "Connect Client")) { client.Connect("localhost", 1337); GameObject.Instantiate(PlayerPrefab, Vector3.zero, Quaternion.identity); } GUI.enabled = client.Connected; if (GUI.Button(new Rect(130, 0, 120, 20), "Disconnect Client")) { client.Disconnect(); } // server GUI.enabled = !server.Active; if (GUI.Button(new Rect(0, 25, 120, 20), "Start Server")) { server.Start(1337); } GUI.enabled = server.Active; if (GUI.Button(new Rect(130, 25, 120, 20), "Stop Server")) { server.Stop(); } GUI.enabled = true; }
public void Start(string ip, int port) { _client.OnConnected += OnConnect; _client.OnDisconnected += OnDisconnect; _client.OnData += MessageRecieve; _client.Connect(ip, port); }
public void ConnectToServer(string ip, int port, string playerSessionId) { Debug.Log($"BADNetworkClient ConnectToServer {ip}, {port}, {playerSessionId}"); _playerSessionId = playerSessionId; // had to set these to 0 or else the TCP connection would timeout after the default 5 seconds. // TODO: Investivate further. _client.SendTimeout = 0; _client.ReceiveTimeout = 0; _client.Connect(ip, port); }
static void Main(string[] args) { client = new Telepathy.Client(); client.Connect("localhost", 1337); Task.Run(() => { while (client.Connected) { Telepathy.Message msg; while (client.GetNextMessage(out msg)) { // clientの場合、msg.connectionIdは常に0が格納されている switch (msg.eventType) { case Telepathy.EventType.Connected: Console.WriteLine("Telepathy.EventType.Connected : msg.connectionId=" + msg.connectionId); break; case Telepathy.EventType.Data: Console.WriteLine("Telepathy.EventType.Data : msg.connectionId=" + msg.connectionId + ", msg.data" + System.Text.Encoding.UTF8.GetString(msg.data)); break; case Telepathy.EventType.Disconnected: Console.WriteLine("Telepathy.EventType.Disconnected : msg.connectionId=" + msg.connectionId); break; } } } }); bool break_flag = false; while (break_flag == false) { ConsoleKey k = Console.ReadKey().Key; switch (k) { case ConsoleKey.Spacebar: Console.WriteLine("send massage from client..."); client.Send(System.Text.Encoding.UTF8.GetBytes("send message from server...")); break; case ConsoleKey.Escape: break_flag = true; break; } } client.Disconnect(); }
public void StartClient() { client = new Telepathy.Client(); client.Connect(serverIP, port); }
public override void ClientConnect(string address) => client.Connect(address, port);