public Reciever() { logger = DependencyResolver.Get <ILogger>(); chatCore = DependencyResolver.Get <IChatCore>(); self = this as IReciever; }
private static InputHandler NewHandler( Stream inputStream, IOutputHandler outputHandler, IReciever reciever, IRequestProcessIdentifier requestProcessIdentifier, IRequestRouter requestRouter, IResponseRouter responseRouter, Action <CancellationTokenSource> action) { var cts = new CancellationTokenSource(); if (!System.Diagnostics.Debugger.IsAttached) { cts.CancelAfter(TimeSpan.FromSeconds(5)); } action(cts); var handler = new InputHandler( inputStream, outputHandler, reciever, requestProcessIdentifier, requestRouter, responseRouter, Substitute.For <ILoggerFactory>()); handler.Start(); cts.Wait(); Task.Delay(10).Wait(); return(handler); }
protected override void Setup() { _senders = new ISender[0]; _recievers = new IReciever[1]; _recievers[0] = new UDPOSCReciever(10000) { IsQueueing = true, //onLatestDataRecieved = (msg) => //{ // if (msg.IsBundle()) // { // //Debug.LogError("Not implemented"); // var bundle = msg as OSCBundle; // GetProjectionMatrix(bundle); // } // else // { // Debug.Log($"UDP OSCMessage (Thread) : Address = {msg.Address} Data = {msg.Data[0].ToString()}"); // } //}, onDataRecieved = (msg) => { if (msg.IsBundle()) { var bundle = msg as OSCBundle; GetProjectionMatrix(bundle); } else { Debug.Log($"UDP OSCMessage : Address = {msg.Address} Data = {msg.Data[0].ToString()}"); } } }; }
public InputHandler( Stream input, IOutputHandler outputHandler, IReciever reciever, IRequestProcessIdentifier requestProcessIdentifier, IRequestRouter <IHandlerDescriptor> requestRouter, IResponseRouter responseRouter, ILoggerFactory loggerFactory, ISerializer serializer ) { if (!input.CanRead) { throw new ArgumentException($"must provide a readable stream for {nameof(input)}", nameof(input)); } _input = input; _outputHandler = outputHandler; _reciever = reciever; _requestProcessIdentifier = requestProcessIdentifier; _requestRouter = requestRouter; _responseRouter = responseRouter; _serializer = serializer; _logger = loggerFactory.CreateLogger <InputHandler>(); _scheduler = new ProcessScheduler(loggerFactory); _inputThread = new Thread(ProcessInputStream) { IsBackground = true, Name = "ProcessInputStream" }; }
public virtual void Register(IReciever iReciever, ushort[] msgId) { if (null == iReciever || null == msgId || msgId.Length <= 0) return; for (int i = 0; i < msgId.Length; i++) { m_msgSingleRecieverMap[msgId[i]] = iReciever; } }
private void UserControl1_Load(object sender, EventArgs e) { Application.AddMessageFilter(this); //Function to check the events. calculator = new Calculator(20, 10); addCmd = new AddCommand(calculator); subCmd = new SubtractCommand(calculator); mulCmd = new MultiplyCommand(calculator); divCmd = new DividerCommand(calculator); }
public void RegisterDependcy(IReciever regReciever) { OnRegisterReciever += regReciever.OnRegistered_EventHandler; OnRegisterReciever?.Invoke(this, new RegRecieverData() { owner = this }); OnRegisterReciever -= regReciever.OnRegistered_EventHandler; if (regReciever.Owner == this) { Reciever = regReciever; } }
public virtual void RemoveMessage(IReciever iReciever, ushort[] msgId) { if (null == iReciever || null == msgId || msgId.Length <= 0) return; lock (m_syncRoot) { for (int i = 0; i < msgId.Length; i++) { if (m_msgSingleRecieverMap.ContainsKey(msgId[i])) m_msgSingleRecieverMap.Remove(msgId[i]); } } }
public ServerConnection(string ip, int port) { Ip = ip; Port = port; Client = new TcpClient(); reciever = DependencyResolver.Get <IReciever>(); sender = DependencyResolver.Get <ISender>(); commandHandler = DependencyResolver.Get <ICommandHandler>(); disconnector = DependencyResolver.Get <IDisconnector>(); timer = new System.Timers.Timer(60 * 1000); timer.Elapsed += delegate { sender.Ping(); }; timer.AutoReset = true; timer.Start(); }
public Connection( Stream input, IOutputHandler outputHandler, IReciever reciever, IRequestProcessIdentifier requestProcessIdentifier, IRequestRouter requestRouter, IResponseRouter responseRouter, ILoggerFactory loggerFactory) { _requestRouter = requestRouter; _inputHandler = new InputHandler( input, outputHandler, reciever, requestProcessIdentifier, requestRouter, responseRouter, loggerFactory ); }
public Connection( Stream input, IOutputHandler outputHandler, IReciever reciever, IRequestProcessIdentifier requestProcessIdentifier, IRequestRouter <IHandlerDescriptor> requestRouter, IResponseRouter responseRouter, ILoggerFactory loggerFactory, ISerializer serializer) { _requestRouter = requestRouter; _inputHandler = new InputHandler( input, outputHandler, reciever, requestProcessIdentifier, requestRouter, responseRouter, loggerFactory, serializer ); }
public DividerCommand(IReciever reciever) : base(reciever) { }
public MultiplyCommand(IReciever reciever) : base(reciever) { }
public AddCommand(IReciever reciever) : base(reciever) { }
public static JsonRpcServerOptions WithReciever(this JsonRpcServerOptions options, IReciever reciever) { options.Reciever = reciever; return(options); }
public CommandBase(IReciever reciever) { _reciever = reciever; }
public ACommand(IReciever reciever) { reciever_ = reciever; }
public Multiply(IReciever reciever) : base(reciever) { }
/// <summary> /// Unregister a specified reciever /// </summary> /// <param name="rec">The rec.</param> internal void UnRegister(IReciever rec) { _idToReciever.Remove(rec.getMyName()); }
public CreateCommand(IReciever reciever) : base(reciever) { }
public ReadCommand(IReciever reciever) : base(reciever) { }
public NetProcessorAbs(IMessageQueue msgQueue, IEngine engine, IReciever reciever) { RegisterDependcy(msgQueue); RegisterDependcy(engine); RegisterDependcy(reciever); }
public override void Register(IReciever iReciever, ushort[] msgId) { base.Register(iReciever, msgId); }
public Command(IReciever reciever) { this.reciever = reciever; }
protected override void Setup() { _senders = new ISender[6]; _recievers = new IReciever[6]; // tcp osc _senders[0] = new TCPOSCSender(MY_ADDRESS, 20000); _recievers[0] = new TCPOSCReciever(MY_ADDRESS, 20000) { IsQueueing = true, onLatestDataRecieved = (msg) => { if (msg.IsBundle()) { Debug.LogError("Not implemented"); } else { Debug.Log($"UDP OSCMessage (Thread) : Address = {msg.Address} Data = {msg.Data[0].ToString()}"); } }, onDataRecieved = (msg) => { if (msg.IsBundle()) { Debug.LogError("Not implemented"); } else { Debug.Log($"UDP OSCMessage : Address = {msg.Address} Data = {msg.Data[0].ToString()}"); } } }; // udp osc _senders[1] = new UDPOSCSender(MY_ADDRESS, 20001); _recievers[1] = new UDPOSCReciever(20001) { IsQueueing = true, onLatestDataRecieved = (msg) => { if (msg.IsBundle()) { Debug.LogError("Not implemented"); } else { Debug.Log($"UDP OSCMessage (Thread) : Address = {msg.Address} Data = {msg.Data[0].ToString()}"); } }, onDataRecieved = (msg) => { if (msg.IsBundle()) { Debug.LogError("Not implemented"); } else { Debug.Log($"UDP OSCMessage : Address = {msg.Address} Data = {msg.Data[0].ToString()}"); } } }; // tcp _senders[2] = new BaseTCPSender(MY_ADDRESS, 20002); _recievers[2] = new BaseTCPReciever <string>(MY_ADDRESS, 20002) { IsQueueing = true, onLatestDataRecieved = (str) => { Debug.Log("(Thread) " + str); }, onDataRecieved = (str) => { Debug.Log(str); } }; // udp _senders[3] = new BaseUDPSender(MY_ADDRESS, 20003); _recievers[3] = new BaseUDPReciever <string>(20003) { IsQueueing = true, onLatestDataRecieved = (str) => { Debug.Log("(Thread) " + str); }, onDataRecieved = (str) => { Debug.Log(str); } }; // tcp json _senders[4] = new TCPJsonSender(MY_ADDRESS, 20004); _recievers[4] = new TCPJsonReciever(MY_ADDRESS, 20004) { IsQueueing = true, onLatestDataRecieved = (msg) => { var recievedData = JsonUtility.FromJson <BaseJsonData>(msg); switch (recievedData.className) { case nameof(SampleJsonData): var data = JsonUtility.FromJson <SampleJsonData>(msg); Debug.Log($"recieved samplejsondata (thread) : test1 = {data.test1} test2 = {data.test2} test3 = {data.test3} test4 = {data.test4}"); break; case nameof(SampleJsonData2): var data2 = JsonUtility.FromJson <SampleJsonData2>(msg); Debug.Log($"recieved samplejsondata2 (thread) : test5 = {data2.test5} test6 = {data2.test6} test7 = {data2.test7} test8 = {data2.test8}"); break; } }, onDataRecieved = (msg) => { var recievedData = JsonUtility.FromJson <BaseJsonData>(msg); switch (recievedData.className) { case nameof(SampleJsonData): var data = JsonUtility.FromJson <SampleJsonData>(msg); Debug.Log($"recieved samplejsondata : test1 = {data.test1} test2 = {data.test2} test3 = {data.test3} test4 = {data.test4}"); break; case nameof(SampleJsonData2): var data2 = JsonUtility.FromJson <SampleJsonData2>(msg); Debug.Log($"recieved samplejsondata2 : test5 = {data2.test5} test6 = {data2.test6} test7 = {data2.test7} test8 = {data2.test8}"); break; } } }; // udp json _senders[5] = new UDPJsonSender(MY_ADDRESS, 20005); _recievers[5] = new UDPJsonReciever(20005) { IsQueueing = true, onLatestDataRecieved = (msg) => { var recievedData = JsonUtility.FromJson <BaseJsonData>(msg); switch (recievedData.className) { case nameof(SampleJsonData): var data = JsonUtility.FromJson <SampleJsonData>(msg); Debug.Log($"recieved samplejsondata (thread) : test1 = {data.test1} test2 = {data.test2} test3 = {data.test3} test4 = {data.test4}"); break; case nameof(SampleJsonData2): var data2 = JsonUtility.FromJson <SampleJsonData2>(msg); Debug.Log($"recieved samplejsondata2 (thread) : test5 = {data2.test5} test6 = {data2.test6} test7 = {data2.test7} test8 = {data2.test8}"); break; } }, onDataRecieved = (msg) => { var recievedData = JsonUtility.FromJson <BaseJsonData>(msg); switch (recievedData.className) { case nameof(SampleJsonData): var data = JsonUtility.FromJson <SampleJsonData>(msg); Debug.Log($"recieved samplejsondata : test1 = {data.test1} test2 = {data.test2} test3 = {data.test3} test4 = {data.test4}"); break; case nameof(SampleJsonData2): var data2 = JsonUtility.FromJson <SampleJsonData2>(msg); Debug.Log($"recieved samplejsondata2 : test5 = {data2.test5} test6 = {data2.test6} test7 = {data2.test7} test8 = {data2.test8}"); break; } } }; }
public SubtractCommand(IReciever reciever) : base(reciever) { }
/// <summary> /// Registers the specified reciever. /// </summary> /// <param name="rec">The rec.</param> internal void Register(IReciever rec) { _idToReciever.Add(rec.getMyName(), rec); }
public UndoCommand(IReciever reciever) { _reciever = reciever; }
public DMCommand1(IReciever receiver) { this.receiver = receiver; }
public void AddReciever(IReciever Reciever) { this.recievers.Add(Reciever); }
public override void RemoveMessage(IReciever iReciever, ushort[] msgId) { base.RemoveMessage(iReciever, msgId); }
public UpdateCommand(IReciever reciever) : base(reciever) { }
internal JsonRpcServer( Stream input, Stream output, IReciever reciever, IRequestProcessIdentifier requestProcessIdentifier, ILoggerFactory loggerFactory, ISerializer serializer, IServiceCollection services, IEnumerable <Assembly> assemblies) { var outputHandler = new OutputHandler(output, serializer); services.AddLogging(); _reciever = reciever; _serializer = serializer; _collection = new HandlerCollection(); services.AddSingleton <IOutputHandler>(outputHandler); services.AddSingleton(_collection); services.AddSingleton(_serializer); services.AddSingleton <OmniSharp.Extensions.JsonRpc.ISerializer>(_serializer); services.AddSingleton(requestProcessIdentifier); services.AddSingleton(_reciever); services.AddSingleton(loggerFactory); services.AddJsonRpcMediatR(assemblies); services.AddSingleton <IJsonRpcServer>(this); services.AddSingleton <IRequestRouter, RequestRouter>(); services.AddSingleton <IReciever, Reciever>(); services.AddSingleton <IResponseRouter, ResponseRouter>(); var foundHandlers = services .Where(x => typeof(IJsonRpcHandler).IsAssignableFrom(x.ServiceType) && x.ServiceType != typeof(IJsonRpcHandler)) .ToArray(); // Handlers are created at the start and maintained as a singleton foreach (var handler in foundHandlers) { services.Remove(handler); if (handler.ImplementationFactory != null) { services.Add(ServiceDescriptor.Singleton(typeof(IJsonRpcHandler), handler.ImplementationFactory)); } else if (handler.ImplementationInstance != null) { services.Add(ServiceDescriptor.Singleton(typeof(IJsonRpcHandler), handler.ImplementationInstance)); } else { services.Add(ServiceDescriptor.Singleton(typeof(IJsonRpcHandler), handler.ImplementationType)); } } _serviceProvider = services.BuildServiceProvider(); var handlers = _serviceProvider.GetServices <IJsonRpcHandler>().ToArray(); _collection.Add(handlers); _requestRouter = _serviceProvider.GetRequiredService <IRequestRouter>(); _responseRouter = _serviceProvider.GetRequiredService <IResponseRouter>(); _connection = ActivatorUtilities.CreateInstance <Connection>(_serviceProvider, input); }
public DeleteCommand(IReciever reciever) : base(reciever) { }