Esempio n. 1
0
 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);
     }
 }
Esempio n. 2
0
    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();
    }
Esempio n. 3
0
 public void StartClient()
 {
     client = new Telepathy.Client();
     client.Connect(serverIP, port);
 }
Esempio n. 4
0
 public Client()
 {
     _client = new Telepathy.Client(1000);
 }