コード例 #1
0
ファイル: SendMessageHelper.cs プロジェクト: ZyFlux/Projects
 public static void RegisterSendMessage(SendMessageContext context)
 {
     lock (QueuedMessages)
     {
         QueuedMessages.Enqueue(context);
     }
 }
コード例 #2
0
        ISendContext CreateSendContext(DispatchContext executionContext, Uri sourceAddress)
        {
            var context = new SendMessageContext(executionContext.Body);

            context.SetSourceAddress(sourceAddress);

            context.SetDestinationAddress(executionContext.DestinationAddress);
            context.SetResponseAddress(executionContext.ResponseAddress);
            context.SetFaultAddress(executionContext.FaultAddress);

            context.SetRequestId(executionContext.RequestId);
            context.SetConversationId(executionContext.ConversationId);
            context.SetCorrelationId(executionContext.CorrelationId);

            if (executionContext.ExpirationTime.HasValue)
                context.SetExpirationTime(executionContext.ExpirationTime.Value);

            context.SetNetwork(executionContext.Network);
            context.SetRetryCount(executionContext.RetryCount);
            context.SetContentType(executionContext.ContentType);

            foreach (var header in executionContext.Headers)
                context.SetHeader(header.Key, header.Value);

            return context;
        }
コード例 #3
0
    private static void TagResponseUnwrapper(TagActorResponse tar)
    {
        GameObject actorConcerned = Actors.allActors[tar.actorId];
        //Make the send message threadsafe
        SendMessageContext context = new SendMessageContext(actorConcerned, "TagUntag", tar, SendMessageOptions.RequireReceiver);

        SendMessageHelper.RegisterSendMessage(context);
    }
コード例 #4
0
    private static void SuppressResponseUnwrapper(SuppressActorResponse sar)
    {
        //Suppress response reached-> inform accordingly
        GameObject actorConcerned = Actors.allActors[sar.actorId];
        //Make the send message threadsafe
        SendMessageContext context = new SendMessageContext(actorConcerned, "SuppressOnOff", sar, SendMessageOptions.RequireReceiver);

        SendMessageHelper.RegisterSendMessage(context);
    }
コード例 #5
0
    public static void StateUnwrapper(State st) //Also accessed from TraceImplement
    {
        //Send the state to Actor
        GameObject actorConcerned = Actors.allActors[st.actorId];
        //Make the send message threadsafe
        SendMessageContext context = new SendMessageContext(actorConcerned, "NewStateReceived", st, SendMessageOptions.RequireReceiver);

        SendMessageHelper.RegisterSendMessage(context);
    }
コード例 #6
0
    public static void Handle(Log currEvent)
    {
        //Maybe also play an error sound?
        //Send message to the main screen to change the text

        SendMessageContext context = new SendMessageContext(logHead, "NewLog", currEvent, SendMessageOptions.RequireReceiver);

        SendMessageHelper.RegisterSendMessage(context);
    }
コード例 #7
0
    private static void TagReachedResponseUnwrapper(TagReachedResponse trr)
    {
        AutoNext.ResetEverything(); //Disable Auto-next

        GameObject actorConcerned = Actors.allActors[trr.actorId];
        //Make the send message threadsafe
        SendMessageContext context = new SendMessageContext(actorConcerned, "TagReached", trr, SendMessageOptions.RequireReceiver);

        SendMessageHelper.RegisterSendMessage(context);
    }
コード例 #8
0
ファイル: SendMessageHelper.cs プロジェクト: ZyFlux/Projects
    private void Update()
    {
        while (QueuedMessages.Count > 0)
        {
            SendMessageContext context = null;
            lock (QueuedMessages)
            {
                context = QueuedMessages.Dequeue();
            }

            context.Target.SendMessage(context.MethodName, context.Value, context.Options);
        }
    }
コード例 #9
0
ファイル: getSocket.cs プロジェクト: huxianyin/PupilMointor
    void GetMessage()
    {
        while (true)
        {
            var    count    = client.Receive(messTmp);
            string mess_str = Encoding.UTF8.GetString(messTmp, 0, count);
            if (count != 0)
            {
                if (mess_str.Contains("start send data"))
                {
                    receive_data = true;
                    continue;
                }

                if (receive_data == true)
                {
                    string[] data_pieces = mess_str.Split(';');
                    string   data_str    = "{\"data_list\":[";
                    for (int i = 0; i < data_pieces.Length - 1; i++)
                    {
                        if (i != data_pieces.Length - 2)
                        {
                            data_str += data_pieces[i] + ",";
                        }
                        else
                        {
                            data_str += data_pieces[i] + "]}";
                        }
                    }
                    Debug.Log("data_pieces[0]= " + data_pieces[0]);
                    Data frame = ReadToObject <Data>(data_str);
                    message = frame.ToString();
                    Debug.Log(message);
                    SendMessageContext context = new SendMessageContext(view.gameObject, "UpdateData", frame, SendMessageOptions.RequireReceiver);
                    SendMessageHelper.RegisterSendMessage(context);
                }
                else
                {
                    Config frame = ReadToObject <Config>(mess_str);
                    message = frame.ToString();
                    Debug.Log(message);
                    SendMessageContext context = new SendMessageContext(view.gameObject, "ConfigureCharts", frame, SendMessageOptions.RequireReceiver);
                    SendMessageHelper.RegisterSendMessage(context);
                }
            }
            Array.Clear(messTmp, 0, count);
        }
    }
コード例 #10
0
    public static void Handle(TopographyResponse tr)
    {
        switch (tr.topographyType)
        {
        case "RING":
            List <Vector3> positions = RingGenerator.Create(tr.orderedActorIds.Count);

            for (int i = 0; i < tr.orderedActorIds.Count; i++)
            {
                //This hack because of some random GetComponentFastPath error
                GameObject         actorConcerned = Actors.allActors[tr.orderedActorIds[i]];
                SendMessageContext context        = new SendMessageContext(actorConcerned, "MoveToAPosition", positions[i], SendMessageOptions.RequireReceiver);
                SendMessageHelper.RegisterSendMessage(context);
            }
            break;

        default:
            Debug.LogError("Unknown Topography type response received. Doing nothing.");
            break;
        }
    }
コード例 #11
0
    public static void Handle(ActorCreated currEvent)
    {
        GameObject go;

        if (currEvent.resourceId == "" || currEvent.resourceId == null)
        {
            go = Instantiate(VisualizationHandler.modelDictionary["Cube"]); //If type is not set, we want a cube
        }
        else
        {
            go = Instantiate(VisualizationHandler.modelDictionary[currEvent.resourceId]);
        }

        go.transform.name = currEvent.actorId;

        go.transform.parent = TraceImplement.rootOfActors.transform;//Add it to the root G.O.

        //Add this to the dictionary
        Actors.allActors.Add(currEvent.actorId, go);
        if (VisualizationHandler.sysActorNames.Any(go.transform.name.Contains))                            //System actors are different
        {
            go.transform.position = new Vector3(Random.Range(3.5f, 4.5f), 1f, Random.Range(-2.5f, -3.5f)); //A separate area->Marked in the inspector
        }
        else
        {
            go.transform.position = new Vector3(Random.Range(0f, 3.5f), Random.Range(1.25f, 1.9f), Random.Range(-1.5f, 1.5f));
            if (logCreateForEvent)
            {
                //Create a Log of it
                Log newLog = new Log(0, "Actor created : " + currEvent.actorId);
                VisualizationHandler.Handle(newLog);
            }
        }
        SuppressActorResponse sar     = new SuppressActorResponse(go.transform.name, true);
        SendMessageContext    context = new SendMessageContext(go, "SuppressOnOff", sar, SendMessageOptions.RequireReceiver);

        SendMessageHelper.RegisterSendMessage(context);
    }
コード例 #12
0
 protected override void Accept(SendMessageContext message)
 {
 }
コード例 #13
0
 protected override bool Condition(SendMessageContext message)
 {
     return(message.Msg == AppMsgConst.Start);
 }
コード例 #14
0
    public static void HandleResponseReceived(string jsonResponse)
    {
        requestResponseBalance = true; //Just got a response to our request

        Debug.Log("Debugger sent us " + jsonResponse);
        QueryResponse currResponse = (JsonUtility.FromJson <QueryResponse>(jsonResponse));

        switch (currResponse.responseType)
        {
        case "ACTION_RESPONSE":
            //Debug.Log("Received an action response");
            ActionResponse curr = (JsonUtility.FromJson <ActionResponse>(jsonResponse));



            //One ActionResponse includes a list of events for one atomic step
            List <ActorEvent> tempList1 = new List <ActorEvent>();
            foreach (string ev in curr.events)
            {
                tempList1.Add(EventUnwrapper(ev));
            }
            if (tempList1.Count > 0)
            {
                int stepNum = curr.stepNum;

                Trace.visualizationToDispatcherIndexMapper.Add(Trace.allEvents.Count, stepNum);     //stepNum may be -1 for invalid dispatcher steps

                Trace.allEvents.Add(tempList1);
            }
            foreach (State st in curr.states)
            {
                StateUnwrapper(st);
            }

            break;

        case "TOPOGRAPHY_RESPONSE":
            TopographyResponse tr = (JsonUtility.FromJson <TopographyResponse>(jsonResponse));
            //One TopographyResponse includes the type and ordered list of actors, which need to be unwrapped
            TopographyUnwrapper(tr);
            break;

        case "TAG_RESPONSE":
            TagActorResponse tar = (JsonUtility.FromJson <TagActorResponse>(jsonResponse));
            TagResponseUnwrapper(tar);
            break;

        case "TAG_REACHED_RESPONSE":
            TagReachedResponse trr = (JsonUtility.FromJson <TagReachedResponse>(jsonResponse));
            TagReachedResponseUnwrapper(trr);
            break;

        case "EOT_RESPONSE":
            EOTResponseUnwrapper();
            break;

        case "SUPPRESS_ACTOR_RESPONSE":
            SuppressActorResponse sar = JsonUtility.FromJson <SuppressActorResponse>(jsonResponse);
            SuppressResponseUnwrapper(sar);
            break;

        case "STEP_RESPONSE":

            StepResponse sr = (JsonUtility.FromJson <StepResponse>(jsonResponse));

            int id = sr.stepNum;     //Store the StepNum

            Debug.Log("Received response of step " + (id + 1));

            List <ActorEvent> listOfEvents = new List <ActorEvent>();   //This list consists of the net difference we need to do

            //Unwrap specific parts in the same way
            foreach (string ev in sr.events)
            {
                Trace.stepEvents.Add(EventUnwrapper(ev));     //Send these events to a special list
            }
            //State unwrapping is done later as the actors at prior stepNum are not the same as current stepNum
            //StateUnwrapping done in TraceImplement

            //Send message to Reevaluate log- newer logs need to be deleted
            SendMessageContext context = new SendMessageContext(VisualizationHandler.logHead, "ReevaluateList", id + 1, SendMessageOptions.RequireReceiver);
            SendMessageHelper.RegisterSendMessage(context);                                                         //state at n -1 is sent
            break;


        default:
            Debug.LogError("Unable to resolve to a particular class");
            break;
        }
    }