Exemplo n.º 1
0
        private static GAISWriter HandleVideoEnd(GAISReader gr)
        {
            GAISWriter gw = new GAISWriter();

            gw.Write((Int32)OPCODE.VIDEO_END);
            gw.Write(gr.ReadString());
            return(gw);
        }
Exemplo n.º 2
0
        private void startFirst()
        {
            while (!connected)
            {
                try
                {
                    if (client.Available > 0)
                    {
                        gr = new GAISReader(client.GetStream());

                        Int32 id = gr.ReadInt32();
                        nickName = gr.ReadString();

                        foreach (ConnectionInfo c in Server.connections)
                        {
                            if (c.nickName == nickName)
                            {
                                GAISWriter gw = new GAISWriter();
                                gw.Write((Int32)OPCODE.RESPONSE);
                                gw.Write((Int32)RESPONSE.NICKNAME_TAKEN);
                                GAISWriter gwSend = new GAISWriter(client.GetStream());
                                gwSend.Write(gw.ToArray());
                                gwSend.Flush();
                                return;
                            }
                        }
                        ConnectionInfo ci = new ConnectionInfo();
                        ci.nickName = nickName;
                        ci.cl       = client;
                        Server.connections.Add(ci);

                        //create a new thread for this user
                        chatThread = new Thread(new ThreadStart(Run));
                        //start the thread
                        chatThread.Start();

                        connected = true;
                    }
                }
                catch
                {
                    client.Close();
                    connected = true;
                }

                Thread.Sleep(100);
            }
        }
Exemplo n.º 3
0
        private static GAISWriter HandleVideoUpdate(GAISReader gr)
        {
            GAISWriter gw = new GAISWriter();

            gw.Write((Int32)OPCODE.VIDEO_UPDATE);
            gw.Write(gr.ReadString());
            Int32 size = gr.ReadInt32();

            Byte[] arr = gr.ReadBytes(size);

            if (arr.Length > 0)
            {
                gw.Write(size);
                gw.Write(arr);
                return(gw);
            }

            return(null);
        }