Ejemplo n.º 1
0
        protected AgentSessionBase(MessageTransceiver transceiver, string serverSessionId, string sessionClientId)
        {
            this.Transceiver     = transceiver;
            this.ServerSessionId = serverSessionId;
            this.SessionClientId = sessionClientId;

            SessionId   = Guid.NewGuid().ToString("N");
            TimeCreated = DateTime.UtcNow;
            CacheSpan   = TimeSpan.FromHours(1);
            LifeSpan    = TimeSpan.FromHours(8);
            TokenSource = new CancellationTokenSource();
            taskList    = new ConcurrentDictionary <string, Task>(StringComparer.Ordinal);

            _log             = new Lazy <ILog>(() => LogManager.GetLogger(GetType()));
            Output           = new SessionOutput(transceiver, ServerSessionId, SessionClientId);
            WorkDirectory    = Path.Combine(Configuration.WorkDirectory, SessionId);
            ContentDirectory = Path.Combine(WorkDirectory, "content");
            BinDirectory     = Path.Combine(WorkDirectory, "bin");

            Packages = new PackageHost {
                ServerSessionId = serverSessionId,
                Transceiver     = transceiver,
            };

            Applications = new ApplicationHost();
        }
Ejemplo n.º 2
0
 public void MessagesCallback(Message [] messages, MessageTransceiver client, object state)
 {
     foreach (Message message in messages)
     {
         System.Console.WriteLine(message.ToString());
     }
 }
Ejemplo n.º 3
0
        public RuntimeEngine(IModuleConfigData configData)
        {
            _globalInfo = new ModuleGlobalInfo(configData);
            bool isSyncMessenger = _globalInfo.ConfigData.GetProperty <bool>("EngineSyncMessenger");
            // TODO 暂时写死使用LocalTestMaintainer
            // 初始化消息收发器
            MessageTransceiver messageTransceiver = MessageTransceiver.GetTransceiver(_globalInfo, isSyncMessenger);

            messageTransceiver.Clear();
            _controller          = new EngineFlowController(_globalInfo);
            _statusManager       = new RuntimeStatusManager(_globalInfo);
            _syncManager         = new SynchronousManager(_globalInfo);
            _callBackProcessor   = new CallBackProcessor(_globalInfo);
            _debugManager        = EnableDebug ? new DebugManager(_globalInfo) : null;
            _runtimeInfoSelector = new RuntimeInfoSelector(_globalInfo, this);

            _globalInfo.RuntimeInitialize(messageTransceiver, _debugManager);

            _runtimeObjectManager = new RuntimeObjectManager(_globalInfo);

            RuntimeStateMachine stateMachine = new RuntimeStateMachine();

            _globalInfo.StateMachine = stateMachine;

            RegisterMessageHandler();

            _globalInfo.LogService.Print(LogLevel.Info, CommonConst.PlatformLogSession, "RuntimeEngine constructed.");
        }
Ejemplo n.º 4
0
        public SessionOutput(MessageTransceiver transceiver, string serverSessionId, string sessionClientId)
        {
            this.transceiver     = transceiver;
            this.serverSessionId = serverSessionId;
            this.sessionClientId = sessionClientId;

            Writer          = new ScriptOutput();
            Writer.Changed += Output_OnChanged;
        }
Ejemplo n.º 5
0
        public static void DoQuery(out IReadOnlyList <T> results)
        {
            MessageTransceiver <QueryMessage <T> > .Broadcast(new QueryMessage <T>
            {
                Query = _query
            });

            results = _queryCache;
        }
Ejemplo n.º 6
0
        public static void DoDelete(DeleteRequest req)
        {
            MessageTransceiver <DeleteMessage <T> > .Broadcast(new DeleteMessage <T>
            {
                Where = req.Where
            });

            MessageTransceiver <OnDeleteMessage <T> > .Broadcast(new OnDeleteMessage <T>());
        }
Ejemplo n.º 7
0
        public static void DoInsert(InsertRequest req)
        {
            MessageTransceiver <InsertMessage <T> > .Broadcast(new InsertMessage <T>
            {
                Data = req.Data
            });

            MessageTransceiver <OnInsertMessage <T> > .Broadcast(new OnInsertMessage <T>());
        }
Ejemplo n.º 8
0
        public void Wait()
        {
            if (_isWaiting)
            {
                MessageTransceiver <T> .RemoveListener(_onReceive);
            }

            _isWaiting = true;
            MessageTransceiver <T> .AddListener(_onReceive);
        }
Ejemplo n.º 9
0
        public static void DoUpdate(UpdateRequest req)
        {
            MessageTransceiver <UpdateMessage <T> > .Broadcast(new UpdateMessage <T>
            {
                Where  = req.Where,
                Update = req.Update
            });

            MessageTransceiver <OnUpdateMessage <T> > .Broadcast(new OnUpdateMessage <T>());
        }
Ejemplo n.º 10
0
        private void OnReceive(T msg)
        {
            if (_isWaiting)
            {
                MessageTransceiver <T> .RemoveListener(_onReceive);

                _isWaiting = false;
                _msg       = msg;

                _onComplete?.Invoke();
            }
        }
Ejemplo n.º 11
0
        public RuntimeEngine(IModuleConfigData configData)
        {
            _globalInfo = new ModuleGlobalInfo(configData);
            bool isSyncMessenger = _globalInfo.ConfigData.GetProperty <bool>("EngineSyncMessenger");
            // TODO 暂时写死使用LocalTestMaintainer
            // 初始化消息收发器
            MessageTransceiver messageTransceiver = MessageTransceiver.GetTransceiver(_globalInfo, isSyncMessenger);

            _controller    = new EngineFlowController(_globalInfo);
            _statusManager = new RuntimeStatusManager(_globalInfo);
            _syncManager   = new SynchronousManager(_globalInfo);

            _globalInfo.RuntimeInitialize(messageTransceiver, _controller.Debugger);

            _runtimeObjectManager = new RuntimeObjectManager();

            RuntimeStateMachine stateMachine = new RuntimeStateMachine();

            _globalInfo.StateMachine = stateMachine;

            RegisterMessageHandler();
        }
Ejemplo n.º 12
0
        protected AgentSessionBase(MessageTransceiver transceiver, string serverSessionId, string sessionClientId)
        {
            this.Transceiver     = transceiver;
            this.ServerSessionId = serverSessionId;
            this.SessionClientId = sessionClientId;

            SessionId  = Guid.NewGuid().ToString("N");
            utcCreated = DateTime.UtcNow;
            CacheSpan  = TimeSpan.FromHours(1);
            LifeSpan   = TimeSpan.FromHours(8);

            _log             = new Lazy <ILog>(() => LogManager.GetLogger(GetType()));
            Output           = new SessionOutput(transceiver, ServerSessionId, SessionClientId);
            WorkDirectory    = Path.Combine(Configuration.WorkDirectory, SessionId);
            ContentDirectory = Path.Combine(WorkDirectory, "content");
            BinDirectory     = Path.Combine(WorkDirectory, "bin");

            PackageClient = new DomainPackageClient();
            PackageClient.OnPushProjectPackage     += PackageClient_OnPushProjectPackage;
            PackageClient.OnPushApplicationPackage += PackageClient_OnPushApplicationPackage;
            PackageClient.OnPullProjectPackage     += PackageClient_OnPullProjectPackage;
            PackageClient.OnPullApplicationPackage += PackageClient_OnPullApplicationPackage;
        }
Ejemplo n.º 13
0
        public ExampleClient(string hostName, int port)
        {
            MessageTransceiver client = new MessageTransceiver(hostName, port);

            client.RegisterForMessages(new MessagesCallback(MessagesCallback), null);
            client.RegisterForDisconnect(new DisconnectCallback(DisconnectCallback), null);
            client.BeginConnect(new AsyncCallback(this.ConnectCallback), client);

            Message m1 = new Message();

            m1.what = StorageReflectConstants.PR_COMMAND_SETPARAMETERS;
            m1.setBoolean("SUBSCRIBE:*", true);
            m1.setBoolean("SUBSCRIBE:*/*", true);
            m1.setBoolean("SUBSCRIBE:*/*/*", true);
            m1.setBoolean("SUBSCRIBE:*/*/*/*", true);
            m1.setBoolean("SUBSCRIBE:*/*/*/*/*", true);

            client.Send(m1);

            while (true)
            {
                Thread.Sleep(5000);
            }
        }
Ejemplo n.º 14
0
 public AgentDeploySession(MessageTransceiver transceiver, string serverSessionId, string sessionClientId) : base(transceiver, serverSessionId, sessionClientId)
 {
     ApplicationsDirectory = Configuration.ApplicationsDirectory;
 }
Ejemplo n.º 15
0
        public void Close()
        {
            MessageTransceiver <T> .RemoveListener(_onReceive);

            _isWaiting = false;
        }
Ejemplo n.º 16
0
 public void DisconnectCallback(MessageTransceiver client, Exception err, object state)
 {
     Console.WriteLine(err.ToString());
     Console.WriteLine("disconnected");
 }
Ejemplo n.º 17
0
        public void ConnectCallback(IAsyncResult ar)
        {
            MessageTransceiver client = (MessageTransceiver)ar.AsyncState;

            client.EndConnect(ar);
        }
Ejemplo n.º 18
0
 public SlaveController(SlaveContext slaveContext)
 {
     this._transceiver  = slaveContext.MessageTransceiver;
     this._slaveContext = slaveContext;
 }
Ejemplo n.º 19
0
 public void Dispose()
 {
     MessageTransceiver?.Dispose();
     TestGenBlocker?.Dispose();
 }
Ejemplo n.º 20
0
 public void RuntimeInitialize(MessageTransceiver messageTransceiver, DebugManager debugManager)
 {
     this.MessageTransceiver = messageTransceiver;
     this.EventQueue         = new LocalEventQueue <EventInfoBase>(Constants.DefaultEventsQueueSize);
     this.DebugHandle        = new DebuggerHandle(debugManager);
 }
Ejemplo n.º 21
0
 public void Dispose()
 {
     MessageTransceiver?.Dispose();
 }
Ejemplo n.º 22
0
 public AgentBuildSession(MessageTransceiver transceiver, string serverSessionId, string sessionClientId) : base(transceiver, serverSessionId, sessionClientId)
 {
 }