Exemplo n.º 1
0
    public void OnSendBuildInfo(BuildInfo buildInfo)
    {
        BuildRequest req = new BuildRequest(ClientID, buildInfo, SelectBuildManager.Instance.CurrentGameMode == SelectBuildManager.GameMode.Single, UIManager.Instance.GetBaseUIForm <StartMenuPanel>().state == StartMenuPanel.States.Show_Single_HasStory);

        SendMessage(req);
        ClientState = ClientStates.Login;
    }
Exemplo n.º 2
0
    public void CancelMatch()
    {
        CancelMatchRequest request = new CancelMatchRequest(ClientID);

        SendMessage(request);
        ClientState = ClientStates.Login;
    }
Exemplo n.º 3
0
    public void LeaveGame()
    {
        LeaveGameRequest request = new LeaveGameRequest(ClientID);

        SendMessage(request);
        ClientState = ClientStates.Login;
    }
Exemplo n.º 4
0
 private void handleConnectPacket(ConnectPacket p)
 {
     if (this.state == ClientStates.WAITING)
     {
         this.name = p.Name;
         if (p.TargetRoom == -1)
         {
             this.server.createNewRoom(this);
             this.state = ClientStates.CONNECTED;
         }
         else
         {
             if (this.server.roomNum(p.TargetRoom) != -1)
             {
                 this.server.addToRoom(this, p.TargetRoom);
                 this.state = ClientStates.CONNECTED;
             }
             else
             {
                 this.Send(new GameErrorPacket(0x02, "Room full or not existing!"));
             }
         }
     }
     else
     {
         this.Send(new GameErrorPacket(0x01, "Invalid Client State to perform this action!", true, false));
     }
 }
Exemplo n.º 5
0
 public Client(IPEndPoint _remoteEndPoint, DateTime _connectedAt, ClientStates _clientState)
 {
     this.remoteEndPoint = _remoteEndPoint;
     this.connectedAt    = _connectedAt;
     this.clientState    = _clientState;
     this.PageHistory    = new Stack <Page>();
     this.KeyBuffer      = new Queue <Byte>();
     this.CurrentCommand = "";
     this.CommandState   = CommandStates.RegularRouting;
     this.IACState       = IACStates.OutsideIAC;
     this._random        = new Random();
     this._latencyBytes  = new byte[100];
     this._random.NextBytes(this._latencyBytes);
     this._latencyPacketCount = 0;
     this._queuedPage         = null;
     this._queuedPageTimer    = null;
     this._carouselPages      = new List <Tuple <int, int> >();
     this._carouselPages.Add(new Tuple <int, int>(91, 0));
     this._carouselPages.Add(new Tuple <int, int>(91, 1));
     this._carouselPages.Add(new Tuple <int, int>(150, 0));
     this._carouselPages.Add(new Tuple <int, int>(666, 0));
     this._carouselPages.Add(new Tuple <int, int>(999, 3));
     this._carousel        = new Carousel(this);
     this.ShowingNotices   = false;
     this.LastNoticeReadID = -1;
 }
Exemplo n.º 6
0
        public void StartHandshake()
        {
            SendData(Handshake.GenerateC0());
            SendData(Handshake.GenerateC1());

            CurrentState = ClientStates.Handshake_WaitForS0;
        }
 private void MatchmakingClient_StateChanged(object sender, ClientStates state)
 {
     if (state == ClientStates.Joined)
     {
         this.UpdateCustomPropertiesReference();
     }
 }
Exemplo n.º 8
0
        public void Update(ClientInfo clientInfo)
        {
            SyncStatus       = Shared.Enum.SyncStatus.Staged;
            SyncStatusDate   = DateTime.Now;
            IsFamilyMember   = clientInfo.IsFamilyMember;
            IsPartner        = clientInfo.IsPartner;
            MaritalStatus    = clientInfo.MaritalStatus;
            KeyPop           = clientInfo.KeyPop;
            OtherKeyPop      = clientInfo.OtherKeyPop;
            PreventEnroll    = clientInfo.PreventEnroll;
            AlreadyTestedPos = clientInfo.AlreadyTestedPos;
            UserId           = clientInfo.UserId;

            Identifiers.Clear();
            var identifiers = ClientIdentifier.Create(clientInfo);

            AddIdentifiers(identifiers);

            Relationships.Clear();
            var relationships = ClientRelationship.Create(clientInfo);

            AddRelationships(relationships);

            ClientStates.Clear();
            var stats = ClientState.Create(clientInfo);

            AddClientStates(stats);
        }
Exemplo n.º 9
0
    public void OnBeginSingleMode(int chapterID, int levelID)
    {
        ClientState = ClientStates.Matching;
        ClientRequestBase req = new StandaloneStartLevelRequest(ClientID, SelectBuildManager.Instance.CurrentSelectedBuildInfo.BuildID, chapterID, levelID);

        SendMessage(req);
    }
Exemplo n.º 10
0
    public void OnBeginMatch()
    {
        ClientRequestBase req = null;

        req = new MatchRequest(ClientID, SelectBuildManager.Instance.CurrentSelectedBuildInfo.BuildID);
        SendMessage(req);
        ClientState = ClientStates.Matching;
    }
Exemplo n.º 11
0
 private void handleDisconnect(object sender, OnDisconnectEventArgs e)
 {
     Console.WriteLine("Client \"" + this.name + "\" lost Connection!");
     this.state = ClientStates.DISCONNECTED;
     this.server.closeRoom(this.room, this, "Client lost connection!");
     this.handler.CloseConnection();
     this.server.removeClient(this);
 }
Exemplo n.º 12
0
 private void MatchmakingClientService_StateChanged(object sender, ClientStates state)
 {
     if (state != ClientStates.Joined)
     {
         ScreenContext screenContext = new ScreenContext(new MainScene());
         WaveServices.ScreenContextManager.To(screenContext);
     }
 }
Exemplo n.º 13
0
        private void SendC2Handshake()
        {
            tcpClient.GetStream().Write(serverS1RandomBytes, 0, serverS1RandomBytes.Length);
            Connect("app");
            CurrentState = ClientStates.WaitingForAcknowledge;

            HandshakeOver();
        }
Exemplo n.º 14
0
 private void handleClientEndPacket(GameClientEndPacket p)
 {
     Console.WriteLine("Client \"" + this.name + "\" gracefully closed Connection! Message: \"" + p.Message + "\"");
     this.state = ClientStates.DISCONNECTED;
     this.server.closeRoom(this.room, this, "Client closed connection: " + p.Message);
     this.handler.CloseConnection();
     this.server.removeClient(this);
 }
Exemplo n.º 15
0
 private IEnumerator OrderRoutine()
 {
     current_state = ClientStates.Ordering;
     SelectDrink();
     yield return(null);
     //ShoutOrder();
     // print("Can I have a: "+order.NameOfDrink);
     //yield return new WaitForSeconds(ordering_time);
 }
Exemplo n.º 16
0
 public bool IsInState(params LiveState[] states)
 {
     if (null != ClientStates && ClientStates.Any() && states.Length > 0)
     {
         var found = ClientStates.Where(x => states.Contains(x.Status)).ToList();
         return(found.Count == states.Length);
     }
     return(false);
 }
Exemplo n.º 17
0
        public List <ClientState> GetStates(params LiveState[] states)
        {
            if (null != ClientStates && ClientStates.Any() && states.Length > 0)
            {
                return(ClientStates.Where(x => states.Contains(x.Status)).ToList());
            }

            return(new List <ClientState>());
        }
Exemplo n.º 18
0
    public void OnNewClientMessage(Socket sender, MessageClientsStats message)
    {
        //获取客户端信息
        Debug.Log("[服务器]收到一份连接请求");
        foreach (ClientKeys tempkey in Clients.Keys)
        {
            if (tempkey.socket == sender)
            {
                Clients.Remove(tempkey);
                break;
            }
        }
        Socket clientfd = sender;

        //自己用的元素
        ClientKeys      key    = new ClientKeys();
        ClientStates    states = new ClientStates();
        ClientState     state  = new ClientState();
        NetworkPartment part   = new NetworkPartment();
        //发给玩家的信息
        MessageClientsStats stats = new MessageClientsStats();

        int ID = GetEmptyPlayerNetworkID();

        key.NetworkID   = ID;
        state.NetworkID = ID;

        key.socket  = clientfd;
        part.socket = clientfd;

        //交付玩家信息
        foreach (ClientStates s in Clients.Values)
        {
            ClientState FakeStates = new ClientState();
            FakeStates.NetworkID = s.State.NetworkID;
            FakeStates.IsAlive   = s.State.IsAlive;
            FakeStates.Stats     = s.State.Stats;
            FakeStates.NickName  = s.State.NickName;
            Debug.Log(FakeStates);
            Debug.Log(stats);
            stats.clients.Add(FakeStates);
        }
        stats.NetworkID  = ID;
        stats.PlayerName = message.PlayerName;
        stats.clients.Add(state);
        stats.MapID = MapID;

        //开始整合
        state.NickName = message.PlayerName;
        states.State   = state;
        states.Network = part;

        //添加客户端
        Clients.Add(key, states);
        //广播消息
        BroadcastingMessage(JsonUtility.ToJson(stats));
    }
Exemplo n.º 19
0
 public TelnetClient(TcpClient tcpClient, chat.Server sv, int slotNumber)
 {
     this.tcpClient = tcpClient;
     this.sv = sv;
     this.clientState = ClientStates.SENDGREETING;
     this.slotNumber = slotNumber;
     this.chatCommands = new ChatCommands();
     this.userPrefs = new UserPrefs(); // after class creation
 }
Exemplo n.º 20
0
 public ClientTelnetStateObject(TelnetServer server)
 {
     Server        = server;
     Buffer        = new byte[BufferSize];
     Command       = new StringBuilder();
     ClientSocket  = null;
     ColorAccepted = true; // by default
     State         = ClientStates.Handshaking;
 }
Exemplo n.º 21
0
    public void ReadListenfd(Socket listenfd)
    {
        ClientKeys key = new ClientKeys();

        key.socket = listenfd.Accept();
        ClientStates state = new ClientStates();

        state.Network = new NetworkPartment();
        Clients.Add(key, state);
    }
Exemplo n.º 22
0
        public bool IsInAnyState(Guid indexId, params LiveState[] states)
        {
            if (null != ClientStates && ClientStates.Any(x => null != x.IndexClientId && x.IndexClientId == indexId) &&
                states.Length > 0)
            {
                var found = ClientStates.Where(x => states.Contains(x.Status) && x.IndexClientId == indexId).ToList();
                return(found.Count > 0);
            }

            return(false);
        }
Exemplo n.º 23
0
 public static void Stop()
 {
     KillTimers();
     Logger.Log("Killed timers (so)");
     if (State != ClientStates.Idle)
     {
         LogAndInfo("Stopping operation...");
         Server.SetIndicator(IndicatorStates.Off);
         State = ClientStates.Idle;
         KillAllLeagueClientProcesses();
     }
 }
Exemplo n.º 24
0
    private IEnumerator WalkInRoutine()
    {
        current_state = ClientStates.WalkIn;

        var counter = 0.0f;

        while (counter < 1.0f)
        {
            counter           += Time.deltaTime / walkin_time;
            transform.position = Vector3.Lerp(origin, destination, counter);
            transform.forward  = origin - destination;
            yield return(null);
        }
    }
Exemplo n.º 25
0
        public Client()
        {
            CurrentChunkSize = 0;
            MyDataFrame      = new DataFrame();

            CurrentState        = ClientStates.None;
            tcpClient           = new TcpClient();
            random              = new Random();
            serverS1RandomBytes = new byte[HANDSHAKE_RAND_LENGTH];

            sMemory = new MemoryStream();
            sWriter = new BinaryWriter(sMemory);

            StreamId    = 1;
            PublisherId = "";
        }
Exemplo n.º 26
0
    public bool ReadClientfd(Socket clientfd)
    {
        //获取目标
        ClientKeys key = null;

        foreach (ClientKeys k in Clients.Keys)
        {
            if (k.socket == clientfd)
            {
                key = k;
                break;
            }
        }
        ClientStates state = Clients[key];

        //接收
        int count = 0;

        try
        {
            state.Network.ReadBuff = new byte[65535];
            count = clientfd.Receive(state.Network.ReadBuff);
            DecodeMessage(clientfd, state.Network.ReadBuff, count);
        }
        catch (SocketException ex)
        {
            MessageLeaveGame message = new MessageLeaveGame(key.NetworkID);
            BroadcastingMessage(JsonUtility.ToJson(message));

            clientfd.Close();
            Clients.Remove(key);
            Debug.Log("[服务端]信息接收失败!连接被迫关闭,错误信息:" + ex.ToString());
            return(false);
        }
        //客户端关闭
        if (count == 0)
        {
            MessageLeaveGame message = new MessageLeaveGame(key.NetworkID);
            BroadcastingMessage(JsonUtility.ToJson(message));

            clientfd.Close();
            Clients.Remove(key);
            Debug.Log("[服务端]收到一条连接关闭请求");
            return(false);
        }
        return(true);
    }
Exemplo n.º 27
0
        /// <summary>
        /// Inicializuje klienta
        /// </summary>
        /// <exception cref="ObjectDisposedException">
        /// Ak je object v stave _disposed
        /// </exception>
        /// <exception cref="InvalidOperationException">
        /// Ak je klient v stave 'start'
        /// </exception>
        /// <returns>True = start klienta bol uspesny</returns>
        public Boolean Start()
        {
            //je objekt _disposed ?
            if (this._disposed)
            {
                throw new ObjectDisposedException("Object was disposed");
            }

            //ak je klient spusteny
            if (this._clientState == ClientStates.Start)
            {
                throw new InvalidOperationException(String.Format("{0} is already running.", this));
            }

            try
            {
                //zalogujeme
                this.InternalTrace(TraceTypes.Verbose, "Initializing {0}...", this);

                //interny start klienta
                if (!this.InternalStart())
                {
                    return(false);
                }

                //prechod do ineho stavu
                this._clientState = ClientStates.Start;

                //zalogujeme
                this.InternalTrace(TraceTypes.Verbose, "{0} was initialized successfully", this);

                //event oznamujuci uspesny start klienta
                this.OnClientStart(EventArgs.Empty);

                //uspesny start klienta
                return(true);
            }
            catch (Exception ex)
            {
                //trace message
                this.InternalException(ex, "Error during initializing {0}. {1}", this, ex.Message);

                //chybna
                return(false);
            }
        }
Exemplo n.º 28
0
 public void RateBeberage(bool wasOk, List <string> left_out = null)
 {
     this.wasOk     = wasOk;
     received_order = true;
     Invoke("WalkOut", ordering_time);
     if (wasOk)
     {
         if (onPleased != null)
         {
             onPleased();
         }
         text_globe.text = string.Format("<color=green>¡Gracias, está muy rico!</color>");
         ShoutOrder();
     }
     else
     {
         if (onDisappointed != null)
         {
             onDisappointed();
         }
         if (left_out != null && left_out.Count > 0)
         {
             text_globe.text = string.Format("Hey, el {0} no lleva ", order.NameOfDrink);
             for (int i = 0; i < left_out.Count; i++)
             {
                 text_globe.text += string.Format("<color=red>{0}</color>", left_out[i]);
                 if (i < left_out.Count - 1)
                 {
                     text_globe.text += " ni ";
                 }
             }
             Events.OnAddMistake(left_out.Count);
         }
         else
         {
             text_globe.text = "<color=red>¡Esto sabe horrible!</color>";
             Events.OnAddMistake(order.reagents.Length);
         }
         ShoutOrder();
     }
     current_state = ClientStates.Walkout;
 }
Exemplo n.º 29
0
        public virtual void Update()
        {
            if (CanReceiveData())
            {
                var data = ReceivedData();
                var memory = new MemoryStream(data);
                var reader = new EndianBinaryReader(EndianBitConverter.Big, memory);

                while (memory.Position < memory.Length)
                {
                    switch (CurrentState)
                    {
                        case ClientStates.Handshake_WaitForS0:
                            {
                                reader.ReadByte();
                                CurrentState = ClientStates.Handshake_WaitForS1;
                            }
                            break;
                            case ClientStates.Handshake_WaitForS1:
                            {
                                var s1Chunk = reader.ReadBytes(Globals.Handshake_Length);
                                SendData(Handshake.GenerateC2(s1Chunk));
                                CurrentState = ClientStates.Handshake_WaitForS2;
                            }
                            break;
                            case ClientStates.Handshake_WaitForS2:
                            {
                                var s2Chunk = reader.ReadBytes(Globals.Handshake_Length);
                                CurrentState = ClientStates.Handshake_Done;
                            }
                            break;
                            case ClientStates.Handshake_Done:
                            {
                                var chunk = new Chunk();
                                chunk.Load(memory);
                                ParseChunk(chunk);
                            }
                            break;
                    }
                }
            }
        }
Exemplo n.º 30
0
    private IEnumerator WalkOutRoutine()
    {
        current_state = ClientStates.Walkout;
        GetComponent <LookAtPlayer>().enabled = false;
        animator.SetBool("is walking", true);
        transform.forward = destination - origin;
        if (OnClientStandUp != null)
        {
            OnClientStandUp();
        }
        var counter = 0.0f;

        while (counter < 1.0f)
        {
            counter           += Time.deltaTime / walkout_time;
            transform.position = Vector3.Lerp(destination, origin, counter);
            yield return(null);
        }
        End();
    }
Exemplo n.º 31
0
 void ChangeStatus(ClientStates status)
 {
     switch (status)
     {
         case ClientStates.Waiting:
             StatusText.Text = "Waiting...";
             StatusIcon.Fill = (Brush)Resources["RedBrush"];
             InfoText.Text = WaitingInfo;
             break;
         case ClientStates.Injected:
             StatusText.Text = "Injected";
             StatusIcon.Fill = (Brush)Resources["YellowBrush"];
             InfoText.Text = InjectedInfo;
             break;
         case ClientStates.Connected:
             StatusText.Text = "Connected";
             StatusIcon.Fill = (Brush)Resources["GreenBrush"];
             InfoText.Text = ConnectedInfo;
             break;
     }
 }
Exemplo n.º 32
0
        public static void Start()
        {
            try
            {
                if (LOLProcess != null)
                {
                    if (!LOLProcess.HasExited)
                    {
                        LOLProcess.Kill();
                    }
                    LOLProcess.Dispose();
                    LOLProcess = null;
                }
                GameSession.Control();
                StopLOLClient();
                Thread.Sleep(1000);
                if (State != ClientStates.Start && State != ClientStates.Login)
                {
                    if (gameControl != null)
                    {
                        gameControl.Dispose();
                    }
                    gameControl = null;
                    LogAndInfo("Starting operation...");
                    Server.SetIndicator(IndicatorStates.Wait);
                    Thread.Sleep(1000);
                    State = ClientStates.Start;
                    LogAndInfo("Starting League of Legends...");
                    StartLOLClient();

                    LoginTimer  = new Timer(LoginTimerCallback, null, LoginTimerInterval, Timeout.Infinite);
                    gameControl = new Timer(GameControlCallback, null, 30000, Timeout.Infinite);
                }
            }
            catch (Exception x)
            {
                Logger.Log("Start error: " + x.Message);
            }
        }
Exemplo n.º 33
0
        /// <summary>
        /// Ukonci funkciu vrstvy / klienta
        /// </summary>
        /// <exception cref="ObjectDisposedException">
        /// Ak je object v stave _disposed
        /// </exception>
        public void Stop()
        {
            //je objekt _disposed ?
            if (this._disposed)
            {
                throw new ObjectDisposedException("Object was disposed");
            }

            try
            {
                //ak ide o prechod z ineho stavu
                if (this._clientState != ClientStates.Stop)
                {
                    //zalogujeme
                    this.InternalTrace(TraceTypes.Verbose, "Exiting {0}...", this);
                }

                //interny stop klienta
                this.InternalStop();

                //ak ide o prechod z ineho stavu
                if (this._clientState != ClientStates.Stop)
                {
                    //zmena satvu
                    this._clientState = ClientStates.Stop;

                    //zalogujeme
                    this.InternalTrace(TraceTypes.Verbose, "{0} was exited successfully", this);

                    //event o ukonceni klienta
                    this.OnClientStop(EventArgs.Empty);
                }
            }
            catch (Exception ex)
            {
                //zalogujeme
                this.InternalException(ex, "Error during exiting the client {0}. {1}", this, ex);
            }
        }
Exemplo n.º 34
0
        void ChangeStatus(ClientStates status)
        {
            switch (status)
            {
            case ClientStates.Waiting:
                StatusText.Text = "Waiting...";
                StatusIcon.Fill = (Brush)Resources["RedBrush"];
                InfoText.Text   = WaitingInfo;
                break;

            case ClientStates.Injected:
                StatusText.Text = "Injected";
                StatusIcon.Fill = (Brush)Resources["YellowBrush"];
                InfoText.Text   = InjectedInfo;
                break;

            case ClientStates.Connected:
                StatusText.Text = "Connected";
                StatusIcon.Fill = (Brush)Resources["GreenBrush"];
                InfoText.Text   = ConnectedInfo;
                break;
            }
        }
Exemplo n.º 35
0
 protected void SetClientState(ClientStates newState)
 {
     _clientState = newState;
 }
Exemplo n.º 36
0
        private void SetUserName()
        {
            if (lineBuffer.Length < 3 && lineBuffer.Length > 20)
            {
                this.SendToUser("\r\nUsername must be at least 3- and maximum 20 letters\r\n");
                this.SendToUser("Try again:");
                lineBuffer.Clear();
                return;
            }

            foreach(KeyValuePair<int,TelnetClient> telnet in Server.telnets)
            {
                if (telnet.Value.clientState == ClientStates.TEXT && telnet.Value.username == lineBuffer.ToString())
                {
                    this.SendToUser("\r\nUsername already exists.\r\n");
                    this.SendToUser("Try again:");
                    lineBuffer.Clear();
                    return;
                }
            }

            this.username = lineBuffer.ToString();
            lineBuffer.Clear();
            this.clientState = ClientStates.TEXT;
            this.userPrefs.SetAlias(this.username);
            this.SendToUser("\r\nYou're all set. Enjoy your conversation.\r\n");
            chat.Server.SendAll(string.Format("+++ ({0}) {1} +++\r\n", this.slotNumber, this.username));
        }
Exemplo n.º 37
0
        private void EndRead(IAsyncResult iar)
        {
            try
            {
                int byteRead = this.ns.EndRead(iar);
                if (byteRead <1)
                {
                    this.UnexpectedLogout();
                }
                if (byteRead > 0 && inputBuffer[0] == 255 && this.clientState == ClientStates.SENDGREETING)
            {
                this.clientState = ClientStates.USERNAME;
                WelcomeMessage();
            }

            if (byteRead > 0 && inputBuffer[0] != 255 && ( this.clientState == ClientStates.TEXT || this.clientState == ClientStates.USERNAME))
            {
                string input = System.Text.Encoding.ASCII.GetString(inputBuffer,0,byteRead);
                foreach (char chr in input)
                {
                        ProcessChar(chr);
                }
            }

            this.ns.BeginRead(inputBuffer,0,BUFFERLEN, this.EndRead,null);
            }
            catch(System.ObjectDisposedException e)
            {
                Console.WriteLine("User exited");
            }
            catch(System.IO.IOException e)
            {
                Console.WriteLine("User exited2");
            }
        }
Exemplo n.º 38
0
 public void Connect(string ip, int port = 1935)
 {
     tcpClient.Connect(ip, port);
     tcpClient.NoDelay = false;
     CurrentState = ClientStates.Handshaking;
 }
Exemplo n.º 39
0
        private void SendC2Handshake()
        {
            tcpClient.GetStream().Write(serverS1RandomBytes, 0, serverS1RandomBytes.Length);
            Connect("app");
            CurrentState = ClientStates.WaitingForAcknowledge;

            HandshakeOver();
        }
Exemplo n.º 40
0
        public void Update()
        {
            if(tcpClient.Available != 0)
            {
                var buffer = new byte[tcpClient.Available];
                tcpClient.GetStream().Read(buffer, 0, buffer.Length);

                if(CurrentState == ClientStates.Handshaking)
                {
                    if(sMemory.Length < HANDSHAKE_RAND_LENGTH * 2)
                    {
                        sWriter.Write(buffer);
                        if(sMemory.Length >= HANDSHAKE_RAND_LENGTH * 2)
                        {
                            ParseS1Handshake();
                        }
                    }
                    else
                    {
                        ParseS1Handshake();
                    }
                }
                else
                {
                    var memory = new MemoryStream(buffer);
                    var reader = new EndianBinaryReader(EndianBitConverter.Big, memory);

                    while (memory.Position < memory.Length)
                    {
                        reader.ReadBytes(4); //as of now not used data
                        var bodySizeBytes = new byte[] {0, reader.ReadByte(), reader.ReadByte(), reader.ReadByte()};
                        var bodySize = converter.ToUInt32(bodySizeBytes, 0);

                        var messageId = (RtmpMessageTypeId) reader.ReadByte();
                        reader.ReadInt32(); //stream id is not needed as of now

                        switch (messageId)
                        {
                            case RtmpMessageTypeId.SetChunkSize:
                                {
                                    ParseSetChunkSize(reader.ReadInt32());
                                }
                                break;
                            case RtmpMessageTypeId.UserControlMessage:
                                {
                                    //No fawking clue why it's six bytes atm
                                    ParseUserControlMessage(reader.ReadBytes(6));
                                    if(CurrentState == ClientStates.WaitForStreamBeginControl)
                                    {
                                        //Console.WriteLine("SWITCh3");
                                        CurrentState = ClientStates.WaitForConnectResult;
                                    }
                                    if(CurrentState == ClientStates.WaitForPublishStreamBeginResult)
                                    {
                                        //Console.WriteLine("Switch6");
                                        CurrentState = ClientStates.Streaming;
                                        SendChunkSize(100);
                                    }
                                }
                                break;
                            case RtmpMessageTypeId.ServerBandwidth:
                                {
                                    if(CurrentState == ClientStates.WaitingForAcknowledge)
                                    {
                                        //Console.WriteLine("SWITCH1");
                                        SendWindowAcknowledgementSize();
                                        CurrentState = ClientStates.WaitForPeerBandwidth;
                                    }
                                    ParseServerBandwidth(reader.ReadInt32());
                                }
                                break;
                            case RtmpMessageTypeId.ClientBandwitdh:
                                {
                                    if(CurrentState == ClientStates.WaitForPeerBandwidth)
                                    {
                                        //Console.WriteLine("SWITCh2");
                                        CurrentState = ClientStates.WaitForStreamBeginControl;
                                    }
                                    ParseClientBandwidth(reader.ReadInt32(), reader.ReadByte());
                                }
                                break;
                            case RtmpMessageTypeId.Audio:
                                break;
                            case RtmpMessageTypeId.Video:
                                break;
                            case RtmpMessageTypeId.AMF3:
                                break;
                            case RtmpMessageTypeId.Invoke:
                                break;
                            case RtmpMessageTypeId.AMF0:
                                {
                                    var amfReader = new AmfReader();
                                    amfReader.Parse(reader, bodySize);

                                    if(CurrentState == ClientStates.WaitForConnectResult)
                                    {
                                        if (amfReader.amfData.Strings.Contains("_result"))
                                        {
                                            //Console.WriteLine("SWITCH4");
                                            createStream();
                                            CurrentState = ClientStates.WaitForCreateStreamResponse;
                                        }
                                    }
                                    if(CurrentState == ClientStates.WaitForCreateStreamResponse)
                                    {
                                        if (amfReader.amfData.Strings.Contains("_result"))
                                        {
                                            //Console.WriteLine("SWITCH5");
                                            publish(PublisherId);
                                            CurrentState = ClientStates.WaitForPublishStreamBeginResult;
                                        }
                                    }

                                    ParseAmf(amfReader.amfData);
                                }
                                break;
                                case RtmpMessageTypeId.Acknowledgement:
                                ParseAcknowledgement(reader.ReadInt32());
                                break;
                            default:
                                Console.WriteLine(messageId);
                                break;
                        }

                        ParseMessage(messageId, reader);
                    }
                }
            }
        }
Exemplo n.º 41
0
 public ClientStatus()
 {
     InitializeComponent();
     Status = ClientStates.Waiting;
 }
Exemplo n.º 42
0
        void c_StateChanged(object sender, ClientStates NewState)
        {
            Dispatcher.BeginInvoke(new Action(() =>
            {
                cpanel.IsEnabled = NewState == ClientStates.Online;
                label1.Content = NewState.ToString();// +"(" + c.Settings.LastOne.ToString() + ")";

            }), null);
        }