internal void Leave(bool doReturn = true, bool checkLeave = true) { if (checkLeave) { var allowLeave = GetRoom()?.OnLeave(User); if (allowLeave == false) { return; } } if (Rooms.Count != 0) { CurrentRoom = Rooms.Pop(); User.MessageManager.ShownStats = CurrentRoom?.ShownStats ?? ShownStats.Default; } else { CurrentRoom = null; } OnLeave?.Invoke(User); if (doReturn) { GetRoom()?.OnReturn(User); } }
/// <summary> /// 更新状态 /// </summary> public override void Update() { Vector2 pos = Input.MousePositionInConsole; Vector2 cursorPos = new Vector2(pos.X / (int)manager.Graphics.CharWidth, pos.Y); bool enter = positions.Contains(cursorPos) && Input.MouseInConsole; if (enter) { OnEnter?.Invoke(); if (Touch) { if (Input.GetMouseButton(MouseButton.Left)) { OnClick?.Invoke(); } } else { if (Input.GetMouseButtonUp(MouseButton.Left)) { OnClick?.Invoke(); } } } else { OnLeave?.Invoke(); } }
private void Late() { foreach (var other in Check) { if (other?.Associate == default) { continue; } if (!Active.Contains(other)) { OnLeave.Invoke(other.Associate as PhysicsComponent); } } Check.Clear(); foreach (var active in Active) { if (active?.Associate == default) { continue; } Check.Add(active); } }
public void SetConnection(Connection connection) { Connection = connection; Connection.OnClose += (code) => OnLeave?.Invoke(code); Connection.OnError += (message) => OnError?.Invoke(message); Connection.OnMessage += (bytes) => ParseMessage(bytes); }
public void SetConnection(Connection connection) { Connection = connection; Connection.OnClose += (code) => OnLeave?.Invoke(code); // TODO: expose WebSocket error code! // Connection.OnError += (code, message) => OnError?.Invoke(code, message); Connection.OnError += (message) => OnError?.Invoke(0, message); Connection.OnMessage += (bytes) => ParseMessage(bytes); }
/// <summary> /// Called by the <see cref="ColyseusClient" /> upon connection to a room /// </summary> /// <param name="colyseusConnection">The connection created by the client</param> public void SetConnection(ColyseusConnection colyseusConnection) { this.colyseusConnection = colyseusConnection; this.colyseusConnection.OnClose += code => OnLeave?.Invoke(code); // TODO: expose WebSocket error code! // Connection.OnError += (code, message) => OnError?.Invoke(code, message); this.colyseusConnection.OnError += message => OnError?.Invoke(0, message); this.colyseusConnection.OnMessage += bytes => ParseMessage(bytes); }
//Show message in chat room public void ServeClient() { while (true) { var message = new Message(TcpClient.GetStream()); OnMessage?.Invoke(message); if (message.IsClosing()) { OnLeave?.Invoke(this); } } }
public void Remove(Person p) { IConsole link = p; StringBuilder sb = new StringBuilder(); sb.AppendFormat("\n[{0} ушел домой]", p.Name); link.WriteLine(sb); office.Remove(p); OnLeave -= p.Goodbye; OnLeave?.Invoke(this, new OfficeEventArgs(p)); OnCame -= p.Greet; }
private void OnLeftSubNode(Node node) { OnLeave?.Invoke(node); if (lastSubNode == node) { lastSubNode = null; } if (isActivatingNewLink && activatingSubNode == null) { node.ActivatingLinkEnd(); Element.VisualElement.AddToClassList(ActivatingLinkClass); } }
private void FinishLeaving() { if (state == State.Fleeing) { // Drop any excess coins while (Coins > 0) { DropCoin(); } } state = State.None; OnLeave?.Invoke(this); Destroy(gameObject); SpawnPoofCloud(); }
/// <summary> /// gibt zurück ob der mauscursor über der komponente ist /// </summary> /// <param name="location"></param> /// <returns></returns> public virtual bool OnHover(Vector location) { if (location.X > this.location.X && location.X < this.location.X + size.X && this.location.Y < location.Y && this.location.Y + size.Y > location.Y) { if (hovering == false) { OnEnter?.Invoke(this, location); } return(hovering = true); } if (hovering == true) { OnLeave?.Invoke(this, location); } return(hovering = false); }
private void Leaving(ActionPoint sender, Load load) { load.OnDisposed -= CurrentLoadDisposed; ClearCurrentLoadRemovedEvent(load.Route); OnLeave?.Invoke(this, load); if (previousload != null && previousload.Equals(load)) { previousload = null; } if (currentload != null && currentload.Equals(load)) { currentload = null; } }
/// <summary> /// Leave the room. /// </summary> public async Task Leave(bool consented = true) { if (Id != null) { if (consented) { await Connection.Send(new object[] { Protocol.LEAVE_ROOM }); } else { await Connection.Close(); } } else if (OnLeave != null) { OnLeave?.Invoke(NativeWebSocket.WebSocketCloseCode.Normal); } }
/// <summary> /// Leave the room. /// </summary> public void Leave(bool consented = true) { if (Id != null) { if (consented) { Connection.Send(new object[] { Protocol.LEAVE_ROOM }); } else { Connection.Close(); } } else if (OnLeave != null) { OnLeave.Invoke(this, new EventArgs()); } }
/// <summary> /// Leave the room /// </summary> /// <param name="consented">If the user agreed to this disconnection</param> /// <returns>Connection closure depending on user consent</returns> public async Task Leave(bool consented = true) { if (Id != null) { if (consented) { await colyseusConnection.Send(new[] { ColyseusProtocol.LEAVE_ROOM }); } else { await colyseusConnection.Close(); } } else { OnLeave?.Invoke(WebSocketCloseCode.Normal); } }
void OnDisconnected(NetworkEvent netEvent) { if (NodeState == State.Client) { NodeState = State.Uninitialized; Deinit(); } else if (NodeState == State.Server) { OnLeave.TryInvoke(netEvent.ConnectionId); var dId = netEvent.ConnectionId; ConnectionIds.Remove(netEvent.ConnectionId); var payload = new UniStreamWriter().WriteShort(dId.id).Bytes; // Clients are not aware of each other as this is a star network // Send a reliable reserved message to everyone to announce the disconnection Send(Packet.From(CId).With(ReservedTags.ClientLeft, payload), true); } }
public void SetConnection(Connection connection) { Connection = connection; Connection.OnClose += (object sender, EventArgs e) => { if (OnLeave != null) { OnLeave.Invoke(this, e); } }; Connection.OnError += (object sender, ErrorEventArgs e) => { if (OnError != null) { OnError.Invoke(this, e); } }; OnReadyToConnect.Invoke(this, new EventArgs()); }
internal override void DidReceive(object queryObj, Event objEvent, ParseObject objState) { ParseQuery <T> query = (ParseQuery <T>)queryObj; //T obj = ParseClient.Instance.ServicesFromState<T>(objState, query.GetClassName()); // Copyed from internal code //T obj = (T)ObjectServiceExtensions.CreateObjectWithoutData(ParseClient.Instance.Services, query.GetClassName(), objState.ObjectId); T obj = (T)objState; // Fire those events! switch (objEvent) { case Event.Create: OnCreate?.Invoke(query, obj); break; case Event.Enter: OnEnter?.Invoke(query, obj); break; case Event.Update: OnUpdate?.Invoke(query, obj); break; case Event.Leave: OnLeave?.Invoke(query, obj); break; case Event.Delete: OnDelete?.Invoke(query, obj); break; default: throw new NotImplementedException("The following event type has not been handeled " + objEvent); } foreach (EventsCallback <T> eventsCallback in _eventsCallbacks) { eventsCallback(query, objEvent, obj); } }
public override void Update(double deltaTime) { base.Update(deltaTime); if (Input.onHover(ActRectangle)) { OnHover?.Invoke(this, new UiEventArgs(Input.getPosition())); } if (Input.onLeave(ActRectangle)) { OnLeave?.Invoke(this, new UiEventArgs(Input.getPosition())); } if (Input.OnMouseDown(Input.LeftButton) && Input.IsHover(ActRectangle)) { OnDown?.Invoke(this, new UiEventArgs(Input.getPosition(), Input.LeftButton)); } if (Input.OnMouseDown(Input.MiddleButton) && Input.IsHover(ActRectangle)) { OnDown?.Invoke(this, new UiEventArgs(Input.getPosition(), Input.MiddleButton)); } if (Input.OnMouseDown(Input.RightButton) && Input.IsHover(ActRectangle)) { OnDown?.Invoke(this, new UiEventArgs(Input.getPosition(), Input.RightButton)); } if (Input.OnMouseUp(Input.LeftButton) && Input.IsHover(ActRectangle)) { OnUp?.Invoke(this, new UiEventArgs(Input.getPosition(), Input.LeftButton)); } if (Input.OnMouseUp(Input.MiddleButton) && Input.IsHover(ActRectangle)) { OnUp?.Invoke(this, new UiEventArgs(Input.getPosition(), Input.MiddleButton)); } if (Input.OnMouseUp(Input.RightButton) && Input.IsHover(ActRectangle)) { OnUp?.Invoke(this, new UiEventArgs(Input.getPosition(), Input.RightButton)); } }
public virtual void OnBackFrom() { OnLeave.Fire(); }
public void Component_OnLeave(Vector location) => OnLeave?.Invoke(this, location);
public void Bind(Host host) { _host = host; _host.AddHandler((short)LobbyMessages.RoomCreated, (m, c) => { if (RoomCreated != null) { var ds = DataStorage.CreateForRead(m.Body); var roomToken = new Token(); roomToken.ReadFromDs(ds); RoomCreated.Invoke(roomToken); } }); _host.AddHandler((short)LobbyMessages.PlayerLeaved, (m, c) => { if (OnPlayerLeaved != null) { var ds = DataStorage.CreateForRead(m.Body); var playerToken = new Token(); playerToken.ReadFromDs(ds); OnPlayerLeaved.Invoke(playerToken); } }); _host.AddHandler((short)LobbyMessages.SuccesfullyLeaved, (m, c) => { if (OnLeave != null) { OnLeave.Invoke(); } }); _host.AddHandler((short)LobbyMessages.PlayerJoined, (m, c) => { if (OnPlayerJoined != null) { var ds = DataStorage.CreateForRead(m.Body); var playerToken = new Token(); playerToken.ReadFromDs(ds); OnPlayerJoined.Invoke(playerToken); } }); _host.AddHandler((short)LobbyMessages.SuccesfullyJoined, (m, c) => { if (OnJoin != null) { OnJoin.Invoke(); } }); _host.AddHandler((short)LobbyMessages.GameStarted, (m, c) => { if (OnGameStarted != null) { var ds = DataStorage.CreateForRead(m.Body); _roomToken = new Token(); _roomToken.ReadFromDs(ds); OnGameStarted.Invoke(); } }); _host.AddHandler((short)LobbyMessages.GetRoomsResponse, (m, c) => { if (OnRoomInfoRecieved != null) { var roomTokens = new List <Token>(); roomTokens.FillDeserialize(m.Body); OnRoomInfoRecieved.Invoke(roomTokens); } }); }
public void DispatchLeave(string id) { Utilities.Logger.Info($"Client {id} left {Uri}"); OnLeave?.Invoke(id, _manager.Clients.ToArray()); }
public void Leave() { OnLeave?.Invoke(this); }
void Room_OnLeave(object sender, EventArgs e) { Debug.Log("Left room!"); OnLeave?.Invoke(sender, e); }
public void GoHome() { OnLeave?.Invoke(this); }
void OnMessageReceived(NetworkEvent netEvent, bool reliable) { var bytes = netEvent.GetDataAsByteArray(); var packet = Packet.Deserialize(bytes); // If packet is null, it is a "raw" byte array message. // Forward it to everyone if (packet == null) { OnGetBytes.TryInvoke(netEvent.ConnectionId, bytes, reliable); foreach (var r in ConnectionIds) { // Forward to everyone except the original sender and the server if (r == CId || r == netEvent.ConnectionId) { continue; } Send(Packet.From(CId).To(r).With(ReservedTags.PacketForwarding, packet.Serialize()), true); } return; } string reservedTag = packet.Tag.StartsWith("reserved") ? packet.Tag : string.Empty; // If is not a reserved message if (reservedTag == string.Empty) { OnGetPacket.TryInvoke(netEvent.ConnectionId, packet, reliable); if (NodeState != State.Server) { return; } // The server tries to broadcast the packet to everyone else listed as recipients foreach (var r in packet.Recipients) { // Forward to everyone except the original sender and the server if (r == CId.id || r == netEvent.ConnectionId.id) { continue; } Send(Packet.From(CId).To(r).With(ReservedTags.PacketForwarding, packet.Serialize()), true); } return; } // handle reserved messages switch (reservedTag) { case ReservedTags.ServerStopped: OnServerStopped.TryInvoke(); break; case ReservedTags.ClientJoined: ConnectionIds.Add(netEvent.ConnectionId); OnJoin.TryInvoke(netEvent.ConnectionId); break; case ReservedTags.ClientLeft: ConnectionIds.Remove(netEvent.ConnectionId); OnLeave.TryInvoke(netEvent.ConnectionId); break; case ReservedTags.PacketForwarding: OnGetPacket.TryInvoke(netEvent.ConnectionId, packet, reliable); break; } }
public static void Leave() { SetSimulationSpeed(SimulationSpeed.Normal); OnLeave?.Invoke(); SceneManager.LoadSceneAsync("Overworld"); }
public void GoHome() { // logic OnLeave?.Invoke(this); }
public virtual void OnNavigateFrom() { OnLeave.Fire(); }