rendered paste body function mainloop() { #$x=0; $this->eventLog('Logged in.. now listening for events.',0); while (true) { /* * @todo: find optimal byte read */ while ($this->stream = socket_read($this->socket,1024)) { if($this->capturePacket==1) { $this->packet .= $this->stream; if(stristr($this->stream,rn.rn)) { $this->throwEvent(); $this->packet = ''; } } else { if(stristr($this->stream,'Event:')) { $this->eventLog('Incoming event.',0); $this->capturePacket = 1; $this->packet .= $this->stream; } else { /* may not be necessary .. */ $this->packet = ''; } } } } }