Ejemplo n.º 1
0
 public static void NotifyReceivedMessage(DomainEventLoop sender, EventLoopArgs args)
 {
     if (gotDomainLoopEvent != null) gotDomainLoopEvent(sender, args);
 }
Ejemplo n.º 2
0
	private void Loop_ReceivedEvent(DomainEventLoop sender, EventLoopArgs e) {
		Debug.Log("Received event of type " + e.Message.Type + ": " + e.Message.ToJson());
	}
Ejemplo n.º 3
0
 private void ReceivedLoopEvent(DomainEventLoop sender, EventLoopArgs e)
 {
     if (e.Message["type"].AsString() == "godchildren" && onGotGodchild != null) {
         onGotGodchild(new GotGodchildEvent(e.Message));
     }
 }
Ejemplo n.º 4
0
        private void ReceivedLoopEvent(DomainEventLoop sender, EventLoopArgs e)
        {
            // Ignore events not for us
            if (!e.Message["type"].AsString().StartsWith("match.")) return;
            Lock(() => {
                // Update last event ID
                if (e.Message["event"].Has("_id")) {
                    LastEventId = e.Message["event"]["_id"];
                }

                switch (e.Message["type"].AsString()) {
                    case "match.join":
                        var joinEvent = new MatchJoinEvent(Gamer, e.Message);
                        Players.AddRange(joinEvent.PlayersJoined);
                        if (onPlayerJoined != null) onPlayerJoined(this, joinEvent);
                        break;
                    case "match.leave":
                        var leaveEvent = new MatchLeaveEvent(Gamer, e.Message);
                        foreach (var p in leaveEvent.PlayersLeft) Players.Remove(p);
                        if (onPlayerLeft != null) onPlayerLeft(this, leaveEvent);
                        break;
                    case "match.finish":
                        Status = MatchStatus.Finished;
                        if (onMatchFinished != null) onMatchFinished(this, new MatchFinishEvent(Gamer, e.Message));
                        break;
                    case "match.move":
                        var moveEvent = new MatchMoveEvent(Gamer, e.Message);
                        Moves.Add(new MatchMove(moveEvent.PlayerId, moveEvent.MoveData));
                        if (onMovePosted != null) onMovePosted(this, moveEvent);
                        break;
                    case "match.shoedraw":
                        if (onShoeDrawn != null) onShoeDrawn(this, new MatchShoeDrawnEvent(Gamer, e.Message));
                        break;
                    case "match.invite":	// Do not notify them since we are already playing the match
                        break;
                    default:
                        Common.LogError("Unknown match event type " + e.Message["type"]);
                        break;
                }
            });
        }
Ejemplo n.º 5
0
 private void ReceivedLoopEvent(DomainEventLoop sender, EventLoopArgs e)
 {
     string type = e.Message["type"];
     if (type.StartsWith("friend.") && onFriendStatusChange != null) {
         string status = type.Substring(7 /* friend. */);
         onFriendStatusChange(new FriendStatusChangeEvent(status, e.Message));
     }
 }
Ejemplo n.º 6
0
 private void ReceivedLoopEvent(DomainEventLoop sender, EventLoopArgs e)
 {
     if (e.Message["type"].AsString() == "match.invite") {
         if (onMatchInvitation != null) onMatchInvitation(new MatchInviteEvent(Gamer, e.Message));
     }
 }
Ejemplo n.º 7
0
 private void ProcessEvent(HttpResponse res)
 {
     try {
         EventLoopArgs args = new EventLoopArgs(res.BodyJson);
         if (receivedEvent != null) receivedEvent(this, args);
         Cotc.NotifyReceivedMessage(this, args);
     }
     catch (Exception e) {
         Common.LogError("Exception in the event chain: " + e.ToString());
     }
 }