Ejemplo n.º 1
0
        public Form1()
        {
            InitializeComponent();
            getGiftInfo();
            this.displayResult += new messageDelegate(messageUIHandle);
            ws            = new WebSocket("wss://danmuproxy.douyu.com:8504/");
            ws.OnMessage += this.messageRecv;
            ws.OnOpen    += this.socketOpen;
            ws.OnError   += this.socketError;
            ws.Connect();
            ws.Send(this.genDataByte("type@=loginreq/roomid@=" + roomId + "/"));

            nobleDic.Add("1", "骑");
            nobleDic.Add("2", "子");
            nobleDic.Add("3", "伯");
            nobleDic.Add("4", "公");
            nobleDic.Add("5", "国");
            nobleDic.Add("6", "皇");
            nobleDic.Add("7", "游");

            keepTimer.Elapsed  += new System.Timers.ElapsedEventHandler(keepTimerTick);
            keepTimer.AutoReset = true;
        }
Ejemplo n.º 2
0
 public Program()
 {
     messageEvent += new messageDelegate(SayHiEnglish);
     messageEvent += new messageDelegate(SayHiSpanish);
     messageEvent += new messageDelegate(SayHiItalian);
 }
Ejemplo n.º 3
0
        static void ReciveFromServer(IAsyncResult result)
        {
            client.EndReceive(result);

            string query = Encoding.Unicode.GetString(buffer);
            int    index = query.IndexOf('\0');

            query = query.Remove(index);
            string[] parametrs = query.Split();

            switch (parametrs[0])
            {
            case "Message":
                int sender = int.Parse(parametrs[1]);
                if (Form1.OpenDialog.ContainsKey(sender))
                {
                    index = parametrs[0].Length + parametrs[1].Length + 2;
                    string message = query.Substring(index);

                    messageDelegate del = Form1.OpenDialog[sender].ShowMessage;

                    Form1.OpenDialog[sender].Invoke(del, message, false, false);
                }
                break;

            case "Conversation":
                Human friend = Form1.GetFriendAtId(int.Parse(parametrs[1]));

                index = parametrs[0].Length + parametrs[1].Length + 2;
                string messages = query.Substring(index);


                if (Form1.OpenDialog.ContainsKey(friend.UserId))
                {
                    messagesDelegate del = Form1.OpenDialog[friend.UserId].ShowMessages;

                    Form1.OpenDialog[friend.UserId].Invoke(del, messages);
                }
                else
                {
                    Thread thread = new Thread(NewForm);
                    thread.Start(
                        new object[] {
                        messages,
                        friend
                    });
                }
                break;

            case "Select":
                query = query.Substring(7);
                Form1.AddScreen.ShowUsers(query.Split());
                break;

            case "AddFriend":
                Human newFriend = new Human();
                newFriend = Human.Parse(parametrs, 1);

                Program.MainChatWindow.
                ShowConversationPanel(newFriend);
                break;

            case "AddedSuccessfull":
                Program.MainChatWindow.
                ShowConversationPanel(Form1.AddFriend);
                break;



            default:
                break;
            }

            BeginRecive();
        }