public ClientEnd(EventLoop loop, string host, int port) { _loop = loop; _channel = new Channel(); _handle = new Tcp(_loop); _ip = new IPEndPoint(IPAddress.Parse(host), port); _handle.Channel = _channel; _channel.Handle = _handle; _connected = false; }
public TcpHandle(EventLoop loop) : base() { _handle = Libuv.Allocate(uv_handle_type.UV_TCP); _eventLoop = loop; Libuv.uv_tcp_init(loop.Loop, _handle); GCHandle gcHandle = GCHandle.Alloc(this, GCHandleType.Normal); ((uv_handle_t *)_handle)->data = GCHandle.ToIntPtr(gcHandle); }
public ClientProxy(EventLoop loop, List <ServerCfg> servers) { _eventLoop = loop; _clientRpc = new ClientEnd[servers.Count]; for (int idx = 0; idx < servers.Count; idx++) { var cfg = servers[idx]; _clientRpc[idx] = new ClientEnd(_eventLoop, cfg.host, cfg.port); } }
public ServerEnd(EventLoop loop, IDispatcher dispatcher, int port) { _netLoop = loop; //IPEndPoint ep = new IPEndPoint(IPAddress.Any, _port); _tcpHandle = new TcpListen(_netLoop); _tcpHandle.ChannelAddEvent += AddChannel; _ip = new IPEndPoint(IPAddress.Any, port); _tcpHandle.Bind(_ip); _dispatcher = dispatcher; //_dispatcher = new Dispatcher(_loop); }
public Timer(EventLoop loop, Action <object> cb, object state) { _eventLoop = loop; _callback = cb; _state = state; _handle = Libuv.Allocate(uv_handle_type.UV_TIMER); Libuv.uv_timer_init(_eventLoop.Loop, _handle); GCHandle gcHandle = GCHandle.Alloc(this, GCHandleType.Normal); ((uv_handle_t *)_handle)->data = GCHandle.ToIntPtr(gcHandle); }
public Async(EventLoop loop, Action <object> cb, object state) { var handle = Libuv.Allocate(uv_handle_type.UV_ASYNC); _handle = handle; _eventLoop = loop; _callback = cb; _state = state; Libuv.uv_async_init(loop.Loop, _handle, WorkCallback); GCHandle gcHandle = GCHandle.Alloc(this, GCHandleType.Normal); ((uv_handle_t *)_handle)->data = GCHandle.ToIntPtr(gcHandle); }
public RemoteServers(EventLoop eventLoop) { _maps.Add("area", AREA); _maps.Add("connector", CONNECTOR); _maps.Add("chat", CHAT); _maps.Add("gate", GATE); foreach (var kv in _maps) { var cfg = CfgMgr.Instance.GetServerCfg(kv.Key); _servers[kv.Value] = new ClientProxy(eventLoop, cfg); } /* * for(int idx = 0; idx < SERVER_NUM; idx++) * { * _servers[idx] = new ClientProxy( ) * } */ }
void HandlePacket(EventLoop netloop, Channel c, Packet p) { if (_workLoop != netloop) { _workLoop.AddAsyncJob(() => { //byte[] buff = loop.PWriter.Write("abcde"); //c.Send("abcde",loop.PWriter); int xx; string bbb; switch (p.serviceId) { case 1: break; default: break; } netloop.AddAsyncJob(() => { c.Send(); }); //c.Send() }); } else { Packet ret = new Packet(); //byte[] buff = loop.PWriter.Write("abcde"); //c.Send(buff); //c.Send("abcde",loop.PWriter); } }
public Tcp(EventLoop loop) : base(loop) { }
public Dispatcher(EventLoop loop) { _workLoop = loop; _remoteServer = new RemoteServers(loop); }
public RpcClient(EventLoop loop) { _eventLoop = loop; _remoteServers = new RemoteServers(_eventLoop); }
void ForwardPacket(EventLoop netloop, Packet p) { //直接send }
public TcpListen(EventLoop loop) : base(loop) { }