コード例 #1
0
        void socketDataReceived(object sender, DataReceivedEventArgs e)
        {
            wSocket SocketEvent = new wSocket();

            SocketEvent.StrData = Encoding.Default.GetString(e.Data);
            WsDataReceived(this, SocketEvent);
        }
コード例 #2
0
 void socketMessage(object sender, MessageReceivedEventArgs e)
 {
     if (e.Message == "[\"cm\",{\"type\":\"ping\"}]")
     {
         SendMessage("[\"cm\",{\"type\":\"pong\"}]");
     }
     else
     {
         wSocket SocketEvent = new wSocket();
         SocketEvent.StrMessage = e.Message;
         WsMessageReceived(this, SocketEvent);
     }
 }
コード例 #3
0
        void socketError(object sender, SuperSocket.ClientEngine.ErrorEventArgs e)
        {
            wSocket SocketEvent = new wSocket();

            WsError(this, SocketEvent);
        }
コード例 #4
0
        void socketClosed(object sender, EventArgs e)
        {
            wSocket SocketEvent = new wSocket();

            WsClosed(this, SocketEvent);
        }
コード例 #5
0
        void socketOpened(object sender, EventArgs e)
        {
            wSocket SocketEvent = new wSocket();

            WsConnected(this, SocketEvent);
        }
コード例 #6
0
ファイル: Form1.cs プロジェクト: stooged/DeskCastC
 void WS1_WsDataReceived(object sender, wSocket e)
 {
 }
コード例 #7
0
ファイル: Form1.cs プロジェクト: stooged/DeskCastC
        void WS1_WsMessageReceived(object sender, wSocket e)
        {
            AppLog(e.StrMessage);

            if (e.StrMessage.Contains("\"type\":\"STATUS\"") == true || e.StrMessage.Contains("\"type\":\"RESPONSE\"") == true)
            {
                string[] Spl1, Spl2;
                int      pTime;
                if (e.StrMessage.Contains("\"state\":") == true)
                {
                    Spl1 = Regex.Split(e.StrMessage, "\"state\":");
                    int pState = Convert.ToInt32(Spl1[1].Substring(0, 1));
                    if (pState == 2)
                    {
                        SetState(1);
                    }
                    else
                    {
                        SetState(0);
                    }
                }



                if (e.StrMessage.Contains("\"duration\":") == true)
                {
                    Spl1 = Regex.Split(e.StrMessage, "\"duration\":");
                    Spl2 = Regex.Split(Spl1[1], ",");
                    if (Spl2[0] == "null")
                    {
                        Spl2[0] = "0";
                    }
                    pDuration = Convert.ToInt32(Convert.ToDouble(Spl2[0]));
                }



                if (e.StrMessage.Contains("\"current_time\":") == true)
                {
                    Spl1 = Regex.Split(e.StrMessage, "\"current_time\":");
                    Spl2 = Regex.Split(Spl1[1], ",");
                    if (Spl2[0] == "null")
                    {
                        Spl2[0] = "0";
                    }
                    pTime = Convert.ToInt32(Convert.ToDouble(Spl2[0]));
                    TrackTime(pDuration, pTime);
                }



                if (e.StrMessage.Contains("\"volume\":") == true)
                {
                    Spl1 = Regex.Split(e.StrMessage, "\"volume\":");
                    Spl2 = Regex.Split(Spl1[1], ",");
                    if (Spl2[0] == "null")
                    {
                        Spl2[0] = "0";
                    }
                    if (Spl2[0].Length >= 3)
                    {
                        Spl2[0] = Spl2[0].Substring(2, 1);
                    }
                    else
                    {
                        if (Spl2[0] == "1")
                        {
                            Spl2[0] = "10";
                        }
                    }
                    int pVolume = Convert.ToInt32(Spl2[0]);
                    TrackVolume(pVolume);
                }



                if (e.StrMessage.Contains("\"muted\":") == true)
                {
                    Spl1 = Regex.Split(e.StrMessage, "\"muted\":");
                    Spl2 = Regex.Split(Spl1[1], ",");
                    bool pMuteState = Convert.ToBoolean(Spl2[0]);
                    if (pMuteState == false)
                    {
                        Button5.Text = "Mute";
                    }
                    else
                    {
                        Button5.Text = "Unmute";
                    }
                }
            }
        }
コード例 #8
0
ファイル: Form1.cs プロジェクト: stooged/DeskCastC
 void WS1_WsError(object sender, wSocket e)
 {
     AppLog("Error");
     Label3.Text = "";
 }
コード例 #9
0
ファイル: Form1.cs プロジェクト: stooged/DeskCastC
 void WS1_WsClosed(object sender, wSocket e)
 {
     AppLog("Closed");
     Label3.Text = "";
     SetState(0);
 }
コード例 #10
0
ファイル: Form1.cs プロジェクト: stooged/DeskCastC
 void WS1_WsConnected(object sender, wSocket e)
 {
     AppLog("Connected");
 }