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; }
public void CancelMatch() { CancelMatchRequest request = new CancelMatchRequest(ClientID); SendMessage(request); ClientState = ClientStates.Login; }
public void LeaveGame() { LeaveGameRequest request = new LeaveGameRequest(ClientID); SendMessage(request); ClientState = ClientStates.Login; }
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)); } }
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; }
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(); } }
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); }
public void OnBeginSingleMode(int chapterID, int levelID) { ClientState = ClientStates.Matching; ClientRequestBase req = new StandaloneStartLevelRequest(ClientID, SelectBuildManager.Instance.CurrentSelectedBuildInfo.BuildID, chapterID, levelID); SendMessage(req); }
public void OnBeginMatch() { ClientRequestBase req = null; req = new MatchRequest(ClientID, SelectBuildManager.Instance.CurrentSelectedBuildInfo.BuildID); SendMessage(req); ClientState = ClientStates.Matching; }
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); }
private void MatchmakingClientService_StateChanged(object sender, ClientStates state) { if (state != ClientStates.Joined) { ScreenContext screenContext = new ScreenContext(new MainScene()); WaveServices.ScreenContextManager.To(screenContext); } }
private void SendC2Handshake() { tcpClient.GetStream().Write(serverS1RandomBytes, 0, serverS1RandomBytes.Length); Connect("app"); CurrentState = ClientStates.WaitingForAcknowledge; HandshakeOver(); }
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); }
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); }
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); }
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>()); }
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)); }
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 }
public ClientTelnetStateObject(TelnetServer server) { Server = server; Buffer = new byte[BufferSize]; Command = new StringBuilder(); ClientSocket = null; ColorAccepted = true; // by default State = ClientStates.Handshaking; }
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); }
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); }
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(); } }
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); } }
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 = ""; }
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); }
/// <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); } }
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; }
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; } } } }
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(); }
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; } }
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); } }
/// <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); } }
protected void SetClientState(ClientStates newState) { _clientState = newState; }
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)); }
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"); } }
public void Connect(string ip, int port = 1935) { tcpClient.Connect(ip, port); tcpClient.NoDelay = false; CurrentState = ClientStates.Handshaking; }
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); } } } }
public ClientStatus() { InitializeComponent(); Status = ClientStates.Waiting; }
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); }