public Client(HttpContact contact, ISocketIO socketIO) { _socketIO = socketIO; _channel = contact.GetChannel(); _endPoint = contact.GetRequest().GetPath(); _endPoint = _endPoint.Substring(0, _endPoint.Length - 3); }
public void Send(HttpContact contact) { string o; if(_sendQueue.TryDequeue(out o) && o != null) { contact.GetResponse().SetContent(o); contact.GetChannel().SendMessage(contact.GetResponse()); return; } _liveContact = contact; }
public void XhrPolling(HttpContact contact, string[] args) { if (args.Length < 3) return; _clientLock.EnterReadLock(); var client = GetClient(args[1]); _clientLock.ExitReadLock(); if (client == null) return; if (contact.GetChannel().ToString().Substring(0, contact.GetChannel().ToString().IndexOf(":", StringComparison.Ordinal)) != client.GetChannel().ToString().Substring(0, client.GetChannel().ToString().IndexOf(":", StringComparison.Ordinal))) return; if(!(client.GetChannel() is XhrChannel)) client.Connected(new XhrChannel(contact.GetChannel().ToString().Substring(0, contact.GetChannel().ToString().IndexOf(":", StringComparison.Ordinal)))); var channel = client.GetChannel() as XhrChannel; contact.GetResponse().ContentType = "text/plain"; if (contact.GetRequest().GetMethod() == "GET") { channel.Send(contact); contact.IsAutoSendResponse = false; } else { //POST일 경우 클라 -> 서버 channel.Receive(contact.GetRequest().GetLowPostData()); contact.GetResponse().SetContent("1"); } }