1 Replies - 9192 Views - Last Post: 02 February 2009 - 05:39 PM

#1 BetaWar   User is offline

  • #include "soul.h"
  • member icon

Reputation: 1632
  • View blog
  • Posts: 8,493
  • Joined: 07-September 06

Flash AS3 IRC client

Posted 02 February 2009 - 05:34 PM

The name pretty much says it all.

I am attempting to maek a Flash based IRC client through the use of AS3's Socket class and am running into difficulties.

Here is my code:

var sock:Socket = new Socket("irc.wyldryde.org", 6667);
sock.addEventListener(Event.CONNECT, connection);
sock.addEventListener(Event.CLOSE, closed);
sock.addEventListener(ProgressEvent.SOCKET_DATA, updated);

function connection(e){
	t.text = ">> Connected <<\n";
	//sock.writeUTFBytes("/join #dreamincode");
}
function updated(e){
	t.text += sock.readUTFBytes(sock.bytesAvailable);
}
function closed(e){
	t.text += ">> Connection Closed <<\n";
}

input.addEventListener(KeyboardEvent.KEY_DOWN, updatedInput);
function sendMsg(e){
	sock.writeUTFBytes(input.text);
	sock.flush();
	t.text += input.text+"\n";
	input.text = "";
}

function updatedInput(e){
	if(e.keyCode == 13){
		sendMsg(e);
	}
}


Where input is a text input and t is a textbox.

I fire it up and get this:

Quote

>> Connected <<
:Resurrection.WyldRyde.org NOTICE AUTH :*** Looking up your hostname...

:Resurrection.WyldRyde.org NOTICE AUTH :*** Found your hostname


(In the sandbox, I haven't even got to testing it outside yet...)

But, when I type things in it does nothing, just closes after a while:

Quote

>> Connected <<
:Resurrection.WyldRyde.org NOTICE AUTH :*** Looking up your hostname...

:Resurrection.WyldRyde.org NOTICE AUTH :*** Found your hostname (cached)

/list
ERROR :Closing Link: [72.244.59.168] (Ping timeout)

>> Connection Closed <<


Any ideas?

Is This A Good Question/Topic? 1
  • +

#5 Christopher Elison   User is offline

  • D.I.C Head

Reputation: 39
  • View blog
  • Posts: 230
  • Joined: 29-December 08

Re: Flash AS3 IRC client

Posted 02 February 2009 - 05:39 PM

Have you implemented PING/PONG? IRC relies on this to keep connections alive, the server sends a number to the client (ping) and the client 'pongs' back, for example:
>> :mimas.smeg.net PONG mimas.smeg.net :LAG967560827
<< PING LAG998154577
>> :mimas.smeg.net PONG mimas.smeg.net :LAG998154577
<< PING LAG1028357702
>> :mimas.smeg.net PONG mimas.smeg.net :LAG1028357702


Was This Post Helpful? 2

Page 1 of 1