protected Transport(Options options) { this.Path = options.Path; this.Hostname = options.Hostname; this.Port = options.Port; this.Secure = options.Secure; this.Query = options.Query; this.TimestampParam = options.TimestampParam; this.TimestampRequests = options.TimestampRequests; this.Socket = options.Socket; this.Agent = options.Agent; this.ForceBase64 = options.ForceBase64; this.ForceJsonp = options.ForceJsonp; this.Cookie = options.GetCookiesAsString(); }
private Manager Open(IOpenCallback fn) { var log = LogManager.GetLogger(GlobalHelper.CallerName()); log.Info(string.Format("Manager readyState {0}", ReadyState)); if (ReadyState == ReadyStateEnum.OPEN) { return(this); // allready open } log.Info(string.Format("Manager opening {0}", Uri)); EngineSocket = new Engine(Uri, Options); SocketEngine socket = EngineSocket; ReadyState = ReadyStateEnum.OPENING; var openSub = SOCKETNET35.On.Create(socket, EVENT_OPEN, new ListenerImpl(() => { OnOpen(); if (fn != null) { fn.Call(null); } })); var errorSub = SOCKETNET35.On.Create(socket, EVENT_ERROR, new ListenerImpl((data) => { log.Info("connect_error"); Cleanup(); ReadyState = ReadyStateEnum.CLOSED; EmitAll(EVENT_CONNECT_ERROR, data); if (fn != null) { var err = new SocketException("Connection error", data is Exception ? (Exception)data : null); fn.Call(err); } MaybeReconnectOnOpen(); })); if (_timeout >= 0) { var timeout = (int)_timeout; log.Info(string.Format("connection attempt will timeout after {0}", timeout)); var timer = EasyTimer.SetTimeout(() => { var log2 = LogManager.GetLogger(GlobalHelper.CallerName()); log2.Info("Manager Open start"); log2.Info(string.Format("connect attempt timed out after {0}", timeout)); openSub.Destroy(); socket.Close(); socket.Emit(EVENT_ERROR, new SocketException("timeout")); EmitAll(EVENT_CONNECT_TIMEOUT, timeout); log2.Info("Manager Open finish"); }, timeout); //var taskWorker = new TaskWorker(this); //taskWorker.QueueWorkerWithDelay( // TasksQueue, // null, // (x, e) => // { // var log2 = LogManager.GetLogger(GlobalHelper.CallerName()); // log2.Info("Manager Open start"); // log2.Info(string.Format("connect attempt timed out after {0}", timeout)); // openSub.Destroy(); // socket.Close(); // socket.Emit(EVENT_ERROR, new SocketException("timeout")); // EmitAll(EVENT_CONNECT_TIMEOUT, timeout); // log2.Info("Manager Open finish"); // }, // (x, e) => // { // //action complete // }, // (e) => // { // //display error // }, // (x, e) => // { // // progress change // }, // timeout); lock (Subs) { Subs.Enqueue(new On.TimeoutActionHandle(timer.Stop)); //Subs.Enqueue(new On.ActionHandleImpl(taskWorker.Stop)); } } lock (Subs) { Subs.Enqueue(openSub); Subs.Enqueue(errorSub); } EngineSocket.Open(); return(this); }
public ProbingOnErrorListener(SocketEngine socket, List <Transport> transport, IListener freezeTransport) { this._socket = socket; this._transport = transport; this._freezeTransport = freezeTransport; }
public OnHeartbeatAsListener(SocketEngine socket) { this.socket = socket; }
public EventCloseListener(SocketEngine socket) { this.socket = socket; }
public EventErrorListener(SocketEngine socket) { this.socket = socket; }
public EventPacketListener(SocketEngine socket) { this.socket = socket; }
public EventDrainListener(SocketEngine socket) { this.socket = socket; }