static void Main(string[] args) { ProxyClient proxyClient = new ProxyClient(Int32.Parse(args[0])); proxyClient.Start(); ProxyServer.logger.Info("Proxy Starting"); Console.WriteLine("Press any key to exit."); Console.ReadLine(); }
public static void Route(byte[] bytes, ProxyClient proxyClient) { try { IActor actor; Entity entity = MessageUtil.ByteArrayToEntity(bytes); if (entity.id == "ping") { return; } string typeName = entity.destination; string threadId = System.Threading.Thread.CurrentThread.ManagedThreadId.ToString(); string id = typeName + threadId; if (MessageRouter.actors.TryGetValue(id, out actor)) { actor.PostInit(proxyClient); actor.OnReceive(entity); } else { Type type = Type.GetType(typeName); if (type == null) { MessageRouter.logger.Info(typeName + " is null"); return; } actor = Activator.CreateInstance(type) as IActor; if (MessageRouter.actors.TryAdd(id, actor)) { actor.PostInit(proxyClient); actor.OnReceive(entity); } else { MessageRouter.logger.Info("Unable to add actor " + id); } } } catch (Exception ex) { Console.WriteLine(ex); } }
public void PostInit(ProxyClient pc) { proxyClient = pc; }