IRC CLIENT
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by ricardo.
Hi everybody !!
Just taking a time to visit the comunity and download the new version of PB (Looks great!!).
Im playing with the possibilitie of develop a small IRC client, i done some before in VB.
Now... my questions:
I do connect succesfully
Port = 6663
ConnectionID = OpenNetworkConnection("toast.DAL.net", Port)
Then i need to pass some raw data to the server, in VB it looks like this:
irc.SendData "User " & EMail & " " & irc.LocalHostName & " " & irc.RemoteHost & " :" & RealName & vbCrLf
irc.SendData "NICK " & NickName & vbCrLf
I try to this something similar in PB doing:
If ConnectionID
MessageRequester("PureBasic IRC - Client", "Client connected to server...", 0)
PokeS(TextBuffer, "User [url]mailto:mymail@yahoo.com[/url] 209.13.250.61 ricardo")
Delay (1000)
SendNetworkData(ConnectionID, TextBuffer,1000)
PokeS(TextBuffer, "Nick ricardo")
Delay (1000)
SendNetworkData(ConnectionID, TextBuffer,1000)
EndIf
But something is missing since the server dont let me in and quit me because some timerout of ping.
In VB this easy steps make the server to let me in and then i only need to send some easy raw data and i have a IRC client.
Could some one help me?
My code is a mess but i put it here to see if someone get how to workarround the problem. Thanks in advance.
-------------------------------------------------------------------------------
If InitNetwork() = 0
MessageRequester("Error", "Can't initialize the network !", 0)
End
EndIf
#WINDOW_PARAMETERS = #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget | #PB_Window_SizeGadget
Port = 6663
Buffer = AllocateMemory(0, 1000, 0)
TextBuffer = AllocateMemory(1, 1000, 0)
If OpenWindow(0,100,100, 300, 300, #WINDOW_PARAMETERS ,"IRC CLIENT")
If CreateGadgetList(WindowID())
StringGadget(1, 100, 250, 150, 20, "")
EndIf
ConnectionID = OpenNetworkConnection("toast.DAL.net", Port)
If ConnectionID
MessageRequester("PureBasic - Client", "Client connected to server...", 0)
PokeS(TextBuffer, "User [url]mailto:ricardoarias@yahoo.com[/url] 209.13.250.61 ricardo")
Delay (1000)
SendNetworkData(ConnectionID, TextBuffer,1000)
PokeS(TextBuffer, "Nick ricardo")
Delay (1000)
SendNetworkData(ConnectionID, TextBuffer,1000)
Else
end
EndIf
Repeat
EventID.l = WaitWindowEvent()
;SendNetworkString(ConnectionID, "PING")
Result = ReceiveNetworkData(ConnectionID, Buffer, 1000)
If result
MessageRequester("data",PeekS(Buffer),0)
SendNetworkString(ConnectionID, "PING")
EndIf
Until EventID = #PB_EventCloseWindow
EndIf
CloseNetworkConnection(ConnectionID)
End
Hi everybody !!
Just taking a time to visit the comunity and download the new version of PB (Looks great!!).
Im playing with the possibilitie of develop a small IRC client, i done some before in VB.
Now... my questions:
I do connect succesfully
Port = 6663
ConnectionID = OpenNetworkConnection("toast.DAL.net", Port)
Then i need to pass some raw data to the server, in VB it looks like this:
irc.SendData "User " & EMail & " " & irc.LocalHostName & " " & irc.RemoteHost & " :" & RealName & vbCrLf
irc.SendData "NICK " & NickName & vbCrLf
I try to this something similar in PB doing:
If ConnectionID
MessageRequester("PureBasic IRC - Client", "Client connected to server...", 0)
PokeS(TextBuffer, "User [url]mailto:mymail@yahoo.com[/url] 209.13.250.61 ricardo")
Delay (1000)
SendNetworkData(ConnectionID, TextBuffer,1000)
PokeS(TextBuffer, "Nick ricardo")
Delay (1000)
SendNetworkData(ConnectionID, TextBuffer,1000)
EndIf
But something is missing since the server dont let me in and quit me because some timerout of ping.
In VB this easy steps make the server to let me in and then i only need to send some easy raw data and i have a IRC client.
Could some one help me?
My code is a mess but i put it here to see if someone get how to workarround the problem. Thanks in advance.
-------------------------------------------------------------------------------
If InitNetwork() = 0
MessageRequester("Error", "Can't initialize the network !", 0)
End
EndIf
#WINDOW_PARAMETERS = #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget | #PB_Window_SizeGadget
Port = 6663
Buffer = AllocateMemory(0, 1000, 0)
TextBuffer = AllocateMemory(1, 1000, 0)
If OpenWindow(0,100,100, 300, 300, #WINDOW_PARAMETERS ,"IRC CLIENT")
If CreateGadgetList(WindowID())
StringGadget(1, 100, 250, 150, 20, "")
EndIf
ConnectionID = OpenNetworkConnection("toast.DAL.net", Port)
If ConnectionID
MessageRequester("PureBasic - Client", "Client connected to server...", 0)
PokeS(TextBuffer, "User [url]mailto:ricardoarias@yahoo.com[/url] 209.13.250.61 ricardo")
Delay (1000)
SendNetworkData(ConnectionID, TextBuffer,1000)
PokeS(TextBuffer, "Nick ricardo")
Delay (1000)
SendNetworkData(ConnectionID, TextBuffer,1000)
Else
end
EndIf
Repeat
EventID.l = WaitWindowEvent()
;SendNetworkString(ConnectionID, "PING")
Result = ReceiveNetworkData(ConnectionID, Buffer, 1000)
If result
MessageRequester("data",PeekS(Buffer),0)
SendNetworkString(ConnectionID, "PING")
EndIf
Until EventID = #PB_EventCloseWindow
EndIf
CloseNetworkConnection(ConnectionID)
End
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by Pupil.
Hi, why do you have all these delays? Well now to some small things that caught my attention in your code:
* In VB you have the character 'vbCrLf' -this is possibly a neccessary component that is missing in your PB code.
* You should use 'NetworkClientEvent()' in your event loop,and change 'WaitWindowEvent()' to 'WindowEvent()', when doing this you need to put a delay(1) or similar in an appropriate spot in the event loop.
Below I'll suggest some changes that you can make in your code:
Start with the changes above and see if it helps a bit...
Hi, why do you have all these delays? Well now to some small things that caught my attention in your code:
* In VB you have the character 'vbCrLf' -this is possibly a neccessary component that is missing in your PB code.
* You should use 'NetworkClientEvent()' in your event loop,and change 'WaitWindowEvent()' to 'WindowEvent()', when doing this you need to put a delay(1) or similar in an appropriate spot in the event loop.
Below I'll suggest some changes that you can make in your code:
Code: Select all
EOL$ = Chr(13)+ Chr(10) ; vbCrLf i.e. End of Line Char
sendmsg$ = "User [url]mailto:mymail@yahoo.com[/url] 209.13.250.61 ricardo"+EOL$
sendmsg$ + "Nick ricardo"+EOL$
SendNetworkData(ConnectionID, @sendmsg$, Len(sendmsg$))
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by ricardo.
Hi Pupil, Thanks for you help.
Now i receive an answer telling me that USER has not enought parameters, then i complete the parameters and im GETTING ON THE IRC NOW !!!!!!!!!!!!!! JA JA JA
YES, thanks Pupil.
Onew more question:
If i use the file sending on network... could i have some percent of the transfer?
Thanks
in advace
Hi Pupil, Thanks for you help.
Now i receive an answer telling me that USER has not enought parameters, then i complete the parameters and im GETTING ON THE IRC NOW !!!!!!!!!!!!!! JA JA JA
YES, thanks Pupil.
Onew more question:
If i use the file sending on network... could i have some percent of the transfer?
Thanks
in advace
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by ricardo.
This is my code, please take a look and give me feedback
; Im just learning how to code in PB, then please dont be rude with my faults
; Maybe i done somethings just like a caveman ha ha, per expample using just a Window Event
; To get the events from both windows, but in other way i can't get it to work.
;
; Like a Localhost (127.0.0.1) i using a IRC server VB open source that some guy develop
;
; I hope that some expert guys can correct my faults to learn from them
;
; i need to parse all the raw data from irc server and then do what need to be done
; in every case, just give me time.
;
; Im not sure why my timer (PONG) function dosent works... hmmmm...
;
; Not PrivateMessages at the moment, etc.
Procedure Timer()
EOL$ = Chr(13)+ Chr(10)
Delay(5000)
SendNetworkString(ConnectionID," PONG "+EOL$)
RichEditLocate(0,1000)
EndProcedure
#WINDOW_PARAMETERS = #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget | #PB_Window_SizeGadget
;Port = 6663
;Port = 6667
Buffer = AllocateMemory(0, 10000, 0)
TextBuffer = AllocateMemory(1, 100, 0)
EOL$ = Chr(13)+ Chr(10)
Nick.s = "PureBasicUser"+Str(Random(1000))
Channel.s = "#PureBasic"
email.s = "[url]mailto:none@yahoo.com[/url]"
irc.s = "irc.debian.org"
port.s = "6667"
num.s = "0"
Connecting = 0
LoadImage(1, "CdPlayer.ico")
If InitNetwork() = 0
MessageRequester("Error", "Can't initialize the network !", 0)
End
EndIf
;************************************************************************************ MAIN WINDOW
If OpenWindow(1,100,100, 600, 300, #WINDOW_PARAMETERS ,"IRC CLIENT")
If CreateGadgetList(WindowID())
OpenRichEdit(WindowID(1), 0, 0, 0, 450, 200, "")
StringGadget(14, 5, 275, 540, 20, "")
TextGadget(15, 525, 203, 70, 20, "Connecting",#PB_Text_Border)
ButtonGadget(16, 550, 275, 40, 20, "Send" ,#PB_Button_Default)
TextGadget(17, 5, 225, 50, 20, "Nick",#PB_Text_Border)
StringGadget(18, 60, 225, 100, 20, "PureBasicUser")
ButtonGadget(19, 170, 225, 80, 20, "Connect",#PB_Button_Default )
TextGadget(20, 5, 250, 50, 20, "Channel",#PB_Text_Border)
StringGadget(21, 60, 250, 100, 20, "#PureBasic")
ListIconGadget(22, 450, 0, 150, 200, "Users", 250)
ButtonGadget(23, 440, 205, 80, 20, "Settings")
EndIf
SetRichEditText(0,0, 100, "IRC Pure Basic Client"+EOL$)
;---------------------------------------------------------------------------------------OPTIONS
If OpenPreferences("Settings")
Nick = ReadPreferenceString("Nick","error")
Channel = ReadPreferenceString("Channel","error")
email = ReadPreferenceString("email","error")
irc.s = ReadPreferenceString("irc","error")
port.s = ReadPreferenceString("port","error")
num = ReadPreferenceString("num","error")
Else
;------------------------------------------------------------------------------- SETTINGS WINDOW
Options:
OpenWindow(0,100,100, 350, 180, #WINDOW_PARAMETERS ,"IRC CLIENT - SETTINGS")
If CreateGadgetList(WindowID())
TextGadget(1, 5, 10, 70, 20, "Nick",#PB_Text_Border)
StringGadget(2, 75, 10, 250, 20, Nick)
TextGadget(3, 5, 40, 70, 20, "Channel",#PB_Text_Border)
StringGadget(4, 75, 40, 250, 20, Channel)
TextGadget(5, 5, 70, 70, 20, "e mail",#PB_Text_Border)
StringGadget(6, 75, 70, 250, 20, email)
TextGadget(7, 5, 100, 70, 20, "IRC Server",#PB_Text_Border)
ComboBoxGadget(8, 75, 100, 120, 200,#PB_ComboBox_Editable)
AddGadgetItem(8, -1, "irc.debian.org")
AddGadgetItem(8, -1, "toast.DAL.net")
AddGadgetItem(8, -1, "127.0.0.1")
SetGadgetState(8,Val(num))
TextGadget(9, 200, 100, 50, 20, "Port",#PB_Text_Border)
StringGadget(10, 250, 100, 75, 20, "6667")
ButtonGadget(11, 15, 130, 60, 40, "QUIT" )
ButtonGadget(12, 265, 130, 60, 40, "OK" ,#PB_Button_Default)
EndIf
EndIf
SetGadgetText(18,Nick)
SetGadgetText(21,Channel)
;----------------------------------------------------------------------------------------------
Repeat
EventID.l = WaitWindowEvent()
If Connecting 0
Result = NetworkClientEvent(ConnectionID)
Else
Result = 0
EndIf
If result 0
ReceiveNetworkData(ConnectionID, Buffer, 10000)
Texto.s = PeekS(Buffer)
SetRichEditText(0, -1, -1, RTrim(Texto)+EOL$)
RichEditLocate(0,1000)
If FindString(Texto,":+",0) 0 Or FindString(Texto,":End of /MOTD command.",0) 0
;then the connecting process are finished... we are there!!
SetGadgetText(15, "Connected!")
SendNetworkString(ConnectionID," TIME "+EOL$)
SendNetworkString(ConnectionID," JOIN "+CHANNEL+" "+EOL$) ;Sending a petition to join PB Channel
EndIf
If FindString(Texto,"PING",0) 0
SendNetworkString(ConnectionID," PONG "+EOL$)
SetRichEditText(0, -1, -1, "PONG"+EOL$)
SendNetworkString(ConnectionID," TIME "+EOL$)
RichEditLocate(0,1000)
EndIf
If FindString(Texto,"353 "+Nick,0) 0 ;I DONT KNOW IF THIS CAN BE DONE EASILY : (
Repeat
Pos.l = FindString(Texto,"353 "+Nick,Pos + 1)
Pos1.l = FindString(Texto,Chr(13),Pos + 1)
If Pos 0
T.s = Mid(Texto,Pos + (19 + Len(Nick)),Pos1 - (Pos + 19 + Len(Nick))) + " "
Repeat
Pos2.l = FindString(T," ",Pos2 + 1)
If Pos2 0
User.s = LTrim(RTrim(Mid(T,Pos3,Pos2 - Pos3)))
If User ""
AddGadgetItem(22, Cont, User) ; Add every user
Cont.l = Cont + 1
EndIf
EndIf
Pos3.l = Pos2
Until Pos2 = 0
EndIf
Until Pos = 0
FirstList.l = 1
SetRichEditText(0, 0, -1, "Welcome to " + Channel + " Channel"+EOL$);
SendNetworkString(ConnectionID,"PRIVMSG " + Channel +" : PB IRC CLIENT connected !! "+EOL$)
EndIf
If FindString(Texto,"JOIN :"+ Channel,0)0 And FirstList 0
Pos = FindString(Texto,"353 ",0)
Pos1 = FindString(Texto,"!",Pos)
User = Mid(Texto,2,Pos1 -2)
If User ""
AddGadgetItem(22, Cont, User) ; Add every user
Cont.l = Cont + 1
EndIf
EndIf
vacio$ = Space(10000)
PokeS(Buffer,vacio$,Len(vacio$))
EndIf
If EventID = #PB_EventGadget
Select EventGadgetID()
;------------------------------------------------------------------- OPTIONS WINDOW EVENTS
Case 8
Resultado = GetGadgetState(8)
Select resultado
num = Str(resultado)
Case 0
SetGadgetText(10,"6667")
irc = "irc.debian.org")
port = "6667"
Case 1
SetGadgetText(10,"6663")
irc = "toast.da.net")
port = "6663"
Case 2
SetGadgetText(10,"6667")
irc = "127.0.0.1")
port = "6667"
EndSelect
Case 11
CloseWindow(0)
Case 12
Nick = GetGadgetText(2)
Channel = GetGadgetText(4)
email = GetGadgetText(6)
If CreatePreferences("Settings")
WritePreferenceString("Nick", GetGadgetText(2))
WritePreferenceString("Channel", GetGadgetText(4))
WritePreferenceString("email", GetGadgetText(6))
WritePreferenceString("irc", irc)
WritePreferenceString("port", port)
WritePreferenceString("num", num)
ClosePreferences()
EndIf
CloseWindow(0)
;------------------------------------------------------------------------------------------
Case 16
SendNetworkString(ConnectionID," PRIVMSG #PureBasic : "+ GetGadgetText(14)+EOL$)
SetRichEditText(0, -1, -1,"> "+GetGadgetText(14)+EOL$)
RichEditLocate(0,1000)
Case 19
Connecting = 1
SetRichEditText(0, -1, -1, "Connecting..."+EOL$)
ConnectionID = OpenNetworkConnection(IRC, Val(Port))
If ConnectionID
;Nick = GetGadgetText(5)
ThreadID.l = CreateThread(@Timer(), 0); this pong message suppousely avoid to be disconnected
SetRichEditText(0, -1, -1, "Connected to server... Wait (could take some time!)"+EOL$)
;IRC server need the next info in order to connect the client
sendmsg$ = "PASS 1234567"+EOL$ ; PASSWORD
sendmsg$ + "User " + email + " 209.13.250.61 advance ricardo"+EOL$ ; USER INFO
sendmsg$ + "Nick " + Nick +EOL$ ; NICK
SendNetworkData(ConnectionID, @sendmsg$, Len(sendmsg$))
Else
MessageRequester ("Error","No IRC server founded",0)
SetRichEditText(0, 4, 8, "No IRC server founded")
;End
EndIf
Case 23
Goto Options
EndSelect
EndIf
Until EventID = #PB_EventCloseWindow
EndIf
CloseNetworkConnection(ConnectionID)
KillThread(ThreadID)
End
This is my code, please take a look and give me feedback
; Im just learning how to code in PB, then please dont be rude with my faults
; Maybe i done somethings just like a caveman ha ha, per expample using just a Window Event
; To get the events from both windows, but in other way i can't get it to work.
;
; Like a Localhost (127.0.0.1) i using a IRC server VB open source that some guy develop
;
; I hope that some expert guys can correct my faults to learn from them
;
; i need to parse all the raw data from irc server and then do what need to be done
; in every case, just give me time.
;
; Im not sure why my timer (PONG) function dosent works... hmmmm...
;
; Not PrivateMessages at the moment, etc.
Procedure Timer()
EOL$ = Chr(13)+ Chr(10)
Delay(5000)
SendNetworkString(ConnectionID," PONG "+EOL$)
RichEditLocate(0,1000)
EndProcedure
#WINDOW_PARAMETERS = #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget | #PB_Window_SizeGadget
;Port = 6663
;Port = 6667
Buffer = AllocateMemory(0, 10000, 0)
TextBuffer = AllocateMemory(1, 100, 0)
EOL$ = Chr(13)+ Chr(10)
Nick.s = "PureBasicUser"+Str(Random(1000))
Channel.s = "#PureBasic"
email.s = "[url]mailto:none@yahoo.com[/url]"
irc.s = "irc.debian.org"
port.s = "6667"
num.s = "0"
Connecting = 0
LoadImage(1, "CdPlayer.ico")
If InitNetwork() = 0
MessageRequester("Error", "Can't initialize the network !", 0)
End
EndIf
;************************************************************************************ MAIN WINDOW
If OpenWindow(1,100,100, 600, 300, #WINDOW_PARAMETERS ,"IRC CLIENT")
If CreateGadgetList(WindowID())
OpenRichEdit(WindowID(1), 0, 0, 0, 450, 200, "")
StringGadget(14, 5, 275, 540, 20, "")
TextGadget(15, 525, 203, 70, 20, "Connecting",#PB_Text_Border)
ButtonGadget(16, 550, 275, 40, 20, "Send" ,#PB_Button_Default)
TextGadget(17, 5, 225, 50, 20, "Nick",#PB_Text_Border)
StringGadget(18, 60, 225, 100, 20, "PureBasicUser")
ButtonGadget(19, 170, 225, 80, 20, "Connect",#PB_Button_Default )
TextGadget(20, 5, 250, 50, 20, "Channel",#PB_Text_Border)
StringGadget(21, 60, 250, 100, 20, "#PureBasic")
ListIconGadget(22, 450, 0, 150, 200, "Users", 250)
ButtonGadget(23, 440, 205, 80, 20, "Settings")
EndIf
SetRichEditText(0,0, 100, "IRC Pure Basic Client"+EOL$)
;---------------------------------------------------------------------------------------OPTIONS
If OpenPreferences("Settings")
Nick = ReadPreferenceString("Nick","error")
Channel = ReadPreferenceString("Channel","error")
email = ReadPreferenceString("email","error")
irc.s = ReadPreferenceString("irc","error")
port.s = ReadPreferenceString("port","error")
num = ReadPreferenceString("num","error")
Else
;------------------------------------------------------------------------------- SETTINGS WINDOW
Options:
OpenWindow(0,100,100, 350, 180, #WINDOW_PARAMETERS ,"IRC CLIENT - SETTINGS")
If CreateGadgetList(WindowID())
TextGadget(1, 5, 10, 70, 20, "Nick",#PB_Text_Border)
StringGadget(2, 75, 10, 250, 20, Nick)
TextGadget(3, 5, 40, 70, 20, "Channel",#PB_Text_Border)
StringGadget(4, 75, 40, 250, 20, Channel)
TextGadget(5, 5, 70, 70, 20, "e mail",#PB_Text_Border)
StringGadget(6, 75, 70, 250, 20, email)
TextGadget(7, 5, 100, 70, 20, "IRC Server",#PB_Text_Border)
ComboBoxGadget(8, 75, 100, 120, 200,#PB_ComboBox_Editable)
AddGadgetItem(8, -1, "irc.debian.org")
AddGadgetItem(8, -1, "toast.DAL.net")
AddGadgetItem(8, -1, "127.0.0.1")
SetGadgetState(8,Val(num))
TextGadget(9, 200, 100, 50, 20, "Port",#PB_Text_Border)
StringGadget(10, 250, 100, 75, 20, "6667")
ButtonGadget(11, 15, 130, 60, 40, "QUIT" )
ButtonGadget(12, 265, 130, 60, 40, "OK" ,#PB_Button_Default)
EndIf
EndIf
SetGadgetText(18,Nick)
SetGadgetText(21,Channel)
;----------------------------------------------------------------------------------------------
Repeat
EventID.l = WaitWindowEvent()
If Connecting 0
Result = NetworkClientEvent(ConnectionID)
Else
Result = 0
EndIf
If result 0
ReceiveNetworkData(ConnectionID, Buffer, 10000)
Texto.s = PeekS(Buffer)
SetRichEditText(0, -1, -1, RTrim(Texto)+EOL$)
RichEditLocate(0,1000)
If FindString(Texto,":+",0) 0 Or FindString(Texto,":End of /MOTD command.",0) 0
;then the connecting process are finished... we are there!!
SetGadgetText(15, "Connected!")
SendNetworkString(ConnectionID," TIME "+EOL$)
SendNetworkString(ConnectionID," JOIN "+CHANNEL+" "+EOL$) ;Sending a petition to join PB Channel
EndIf
If FindString(Texto,"PING",0) 0
SendNetworkString(ConnectionID," PONG "+EOL$)
SetRichEditText(0, -1, -1, "PONG"+EOL$)
SendNetworkString(ConnectionID," TIME "+EOL$)
RichEditLocate(0,1000)
EndIf
If FindString(Texto,"353 "+Nick,0) 0 ;I DONT KNOW IF THIS CAN BE DONE EASILY : (
Repeat
Pos.l = FindString(Texto,"353 "+Nick,Pos + 1)
Pos1.l = FindString(Texto,Chr(13),Pos + 1)
If Pos 0
T.s = Mid(Texto,Pos + (19 + Len(Nick)),Pos1 - (Pos + 19 + Len(Nick))) + " "
Repeat
Pos2.l = FindString(T," ",Pos2 + 1)
If Pos2 0
User.s = LTrim(RTrim(Mid(T,Pos3,Pos2 - Pos3)))
If User ""
AddGadgetItem(22, Cont, User) ; Add every user
Cont.l = Cont + 1
EndIf
EndIf
Pos3.l = Pos2
Until Pos2 = 0
EndIf
Until Pos = 0
FirstList.l = 1
SetRichEditText(0, 0, -1, "Welcome to " + Channel + " Channel"+EOL$);
SendNetworkString(ConnectionID,"PRIVMSG " + Channel +" : PB IRC CLIENT connected !! "+EOL$)
EndIf
If FindString(Texto,"JOIN :"+ Channel,0)0 And FirstList 0
Pos = FindString(Texto,"353 ",0)
Pos1 = FindString(Texto,"!",Pos)
User = Mid(Texto,2,Pos1 -2)
If User ""
AddGadgetItem(22, Cont, User) ; Add every user
Cont.l = Cont + 1
EndIf
EndIf
vacio$ = Space(10000)
PokeS(Buffer,vacio$,Len(vacio$))
EndIf
If EventID = #PB_EventGadget
Select EventGadgetID()
;------------------------------------------------------------------- OPTIONS WINDOW EVENTS
Case 8
Resultado = GetGadgetState(8)
Select resultado
num = Str(resultado)
Case 0
SetGadgetText(10,"6667")
irc = "irc.debian.org")
port = "6667"
Case 1
SetGadgetText(10,"6663")
irc = "toast.da.net")
port = "6663"
Case 2
SetGadgetText(10,"6667")
irc = "127.0.0.1")
port = "6667"
EndSelect
Case 11
CloseWindow(0)
Case 12
Nick = GetGadgetText(2)
Channel = GetGadgetText(4)
email = GetGadgetText(6)
If CreatePreferences("Settings")
WritePreferenceString("Nick", GetGadgetText(2))
WritePreferenceString("Channel", GetGadgetText(4))
WritePreferenceString("email", GetGadgetText(6))
WritePreferenceString("irc", irc)
WritePreferenceString("port", port)
WritePreferenceString("num", num)
ClosePreferences()
EndIf
CloseWindow(0)
;------------------------------------------------------------------------------------------
Case 16
SendNetworkString(ConnectionID," PRIVMSG #PureBasic : "+ GetGadgetText(14)+EOL$)
SetRichEditText(0, -1, -1,"> "+GetGadgetText(14)+EOL$)
RichEditLocate(0,1000)
Case 19
Connecting = 1
SetRichEditText(0, -1, -1, "Connecting..."+EOL$)
ConnectionID = OpenNetworkConnection(IRC, Val(Port))
If ConnectionID
;Nick = GetGadgetText(5)
ThreadID.l = CreateThread(@Timer(), 0); this pong message suppousely avoid to be disconnected
SetRichEditText(0, -1, -1, "Connected to server... Wait (could take some time!)"+EOL$)
;IRC server need the next info in order to connect the client
sendmsg$ = "PASS 1234567"+EOL$ ; PASSWORD
sendmsg$ + "User " + email + " 209.13.250.61 advance ricardo"+EOL$ ; USER INFO
sendmsg$ + "Nick " + Nick +EOL$ ; NICK
SendNetworkData(ConnectionID, @sendmsg$, Len(sendmsg$))
Else
MessageRequester ("Error","No IRC server founded",0)
SetRichEditText(0, 4, 8, "No IRC server founded")
;End
EndIf
Case 23
Goto Options
EndSelect
EndIf
Until EventID = #PB_EventCloseWindow
EndIf
CloseNetworkConnection(ConnectionID)
KillThread(ThreadID)
End
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by Pupil.
You're welcome, it's allways nice to be able to help other people.Hi Pupil, Thanks for you help.
Now i receive an answer telling me that USER has not enought parameters, then i complete the parameters and im GETTING ON THE IRC NOW !!!!!!!!!!!!!! JA JA JA
YES, thanks Pupil.
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by MrVainSCL.
Hi ricardo
Some weeks ago, i started to code just for fun an irc client like mirc too! Its not an official project atm... but will be soon (when other stuff/projects are finished!) i hope
I have to much projects started but now i will stop this and will finish one project after the next
First i will finish a very small (98% finished) project but due fact of a bug or let us say a missed feature in PureBasic (ComboBoxGadget Events) i dont get really manage to get the program work as i want ;(( The app is really nothing special so its more demotivated that it dont work atm and i dont really know how to solve the prob atm ;( We will see...
PIII450, 256MB Ram, 6GB HD, RivaTNT, DirectX8.1, SB AWE64, Win2000 + all Updates...
greetz
MrVainSCL! aka Thorsten
Hi ricardo
Some weeks ago, i started to code just for fun an irc client like mirc too! Its not an official project atm... but will be soon (when other stuff/projects are finished!) i hope
I have to much projects started but now i will stop this and will finish one project after the next
First i will finish a very small (98% finished) project but due fact of a bug or let us say a missed feature in PureBasic (ComboBoxGadget Events) i dont get really manage to get the program work as i want ;(( The app is really nothing special so its more demotivated that it dont work atm and i dont really know how to solve the prob atm ;( We will see...
PIII450, 256MB Ram, 6GB HD, RivaTNT, DirectX8.1, SB AWE64, Win2000 + all Updates...
greetz
MrVainSCL! aka Thorsten
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by tranquil.
Hi Ricardo!
Nice work, i took only a small look on your source and I must see that you did the same mistake like we. You code might work but you possible loose datas in the network couse you dont process all of them.
if you do a sendnetworkdata() on the server-side, be sure to check receivenetworkdata() receives the right amount of datas that you have send.
If you use one sendnetworkdata() you possible have to call reveivenetworkdata more then twice times on the other peer side.
receivenetworkdata() is the same as the WinAPI recv_(). Take a look in the WinAPI for correct handling and receiving of datas.
Cheers
Mike
Tranquilizer/ Secretly!
http://www.secretly.de
Registred PureBasic User
Hi Ricardo!
Nice work, i took only a small look on your source and I must see that you did the same mistake like we. You code might work but you possible loose datas in the network couse you dont process all of them.
if you do a sendnetworkdata() on the server-side, be sure to check receivenetworkdata() receives the right amount of datas that you have send.
If you use one sendnetworkdata() you possible have to call reveivenetworkdata more then twice times on the other peer side.
receivenetworkdata() is the same as the WinAPI recv_(). Take a look in the WinAPI for correct handling and receiving of datas.
Cheers
Mike
Tranquilizer/ Secretly!
http://www.secretly.de
Registred PureBasic User
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by MrVainSCL.
I looked in a real hurry to your source and i think you forgot to share your "ConnectionID" to your Timer() procedure...!? If you disable your debugger and dont share the variable, it works fine for me! But if you enable the debugger it will not work! (FRED: Seems there is a debugger bug!?)
Just share your variable and it will work in both modes very fine
Hope this help you a bit... good luck and happy coding 
PIII450, 256MB Ram, 6GB HD, RivaTNT, DirectX8.1, SB AWE64, Win2000 + all Updates...
greetz
MrVainSCL! aka Thorsten
Hi ricardo
ricardo wrote:
Im not sure why my timer (PONG) function dosent works... hmmmm...
I looked in a real hurry to your source and i think you forgot to share your "ConnectionID" to your Timer() procedure...!? If you disable your debugger and dont share the variable, it works fine for me! But if you enable the debugger it will not work! (FRED: Seems there is a debugger bug!?)
Just share your variable and it will work in both modes very fine
Code: Select all
Procedure Timer()
Shared ConnectionID
EOL$ = Chr(13)+ Chr(10)
Delay(500)
SendNetworkString(ConnectionID," PONG "+EOL$)
RichEditLocate(0,1000)
EndProcedure
PIII450, 256MB Ram, 6GB HD, RivaTNT, DirectX8.1, SB AWE64, Win2000 + all Updates...
greetz
MrVainSCL! aka Thorsten
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm