Ejemplo n.º 1
0
    public static void Outline(MessageDropped currEvent)
    {
        Color col = Color.magenta;
        MarkerFunctionality mf = Actors.allActors[currEvent.receiverId].GetComponent <MarkerFunctionality>();

        if (mf.status == 2) //Actor is marked
        {
            col = mf.representationHolding.colourOfMarker;
        }
        Actors.allActors[currEvent.receiverId].GetComponent <ActorFunctionality>().MomentaryOutline(col, outlineTime);
        Actors.allActors[currEvent.senderId].GetComponent <ActorFunctionality>().MomentaryOutline(Color.white, outlineTime);
    }
Ejemplo n.º 2
0
    public static void Handle(MessageDropped currEvent)
    {
        //Do some animation to show disappearing message
        //Currently, this is visualized like MessageReceived
        ActorFunctionality af = Actors.allActors[currEvent.receiverId].GetComponent <ActorFunctionality>();

        af.ReceiveMessageFromQueueDiscreetly();

        if (logCreateForEvent)
        {
            //Create a Log of it
            Log newLog = new Log(0, "Message dropped : " + currEvent.receiverId);
            VisualizationHandler.Handle(newLog);
        }
    }
Ejemplo n.º 3
0
    private static ActorEvent EventUnwrapper(string line)
    {
        ActorEvent ev = (JsonUtility.FromJson <ActorEvent>(line)); //Read into the event parent class

        //Now assign a specific class
        switch (ev.eventType) //Go through all possible event types
        {
        case "ACTOR_CREATED":
            ActorCreated specificActorCreatedEvent = (JsonUtility.FromJson <ActorCreated>(line));
            ev = specificActorCreatedEvent;
            break;

        case "MESSAGE_SENT":
            MessageSent specificMessageSentEvent = (JsonUtility.FromJson <MessageSent>(line));
            ev = specificMessageSentEvent;
            break;

        case "MESSAGE_RECEIVED":
            MessageReceived specificMessageReceivedEvent = (JsonUtility.FromJson <MessageReceived>(line));
            ev = specificMessageReceivedEvent;
            break;

        case "ACTOR_DESTROYED":
            ActorDestroyed specificActorDestroyedEvent = (JsonUtility.FromJson <ActorDestroyed>(line));
            ev = specificActorDestroyedEvent;
            break;

        case "LOG":
            Debug.Log("Log received");
            Log newLog = (JsonUtility.FromJson <Log>(line));
            ev = newLog;
            break;

        case "MESSAGE_DROPPED":
            MessageDropped specificMessageDroppedEvent = (JsonUtility.FromJson <MessageDropped>(line));
            ev = specificMessageDroppedEvent;
            break;

        default:
            //We don't know what this event is
            Debug.LogError("Unknown event encountered in JSON");
            break;
        }
        return(ev);
    }
 /// <summary>
 /// Sends a message to the queue
 /// </summary>
 /// <param name="raw">the message text</param>
 /// <param name="limiter">the message limiter to use with this message, can be null if no limits are in place</param>
 /// <param name="priority">the priority the message has</param>
 /// <example>
 /// A client that automatically replies to pings with an appropriate pong,
 /// the pong message has critical priority and is not limited or validated
 /// <code>
 /// public class TmiPing : TmiConnection
 /// {
 ///     [IrcCommand("PING")]
 ///     protected virtual void OnPing(IrcMessage msg)
 ///     {
 ///         Send($"PONG {msg.RawPrefix}", null, MessagePriority.Critical);
 ///     }
 /// }
 /// </code>
 /// </example>
 protected void Send(string raw, IMessageLimiter limiter, MessagePriority priority = MessagePriority.Default)
 {
     if (!limiter?.Validate(raw) ?? false)
     {
         MessageDropped?.Invoke(this, new MessageDroppedEventArgs(raw, MessageDropReason.Validation));
         return;
     }
     if (sendQueue.Count >= QueueSize)
     {
         MessageDropped?.Invoke(this, new MessageDroppedEventArgs(raw, MessageDropReason.QueueOverflow));
         return;
     }
     lock (sendSyncRoot)
     {
         sendQueue.Enqueue(new QueuedMessage(raw, priority, limiter));
         sender.Signal();
     }
 }
Ejemplo n.º 5
0
 /// <summary>
 /// Called when a message was dropped.
 /// </summary>
 /// <param name="e">the event arguments.</param>
 protected virtual void OnMessageDropped(MessageDroppedEventArgs e)
 {
     MessageDropped?.Invoke(this, e);
 }