Jump to content



Photo

BTCP


  • Please log in to reply
16 replies to this topic

#1 CodyBarrett

CodyBarrett

    I LOVE Juicy Fruit!!!

  • Active Members
  • PipPipPipPipPipPip
  • 1,225 posts

Posted 14 February 2009 - 03:09 AM

I KNOW! there are many a many TCP chat rooms out there in autoitworld of scripting

BUT! i have made a multi client chatroom and im kinda proud of it, so incase you want... the files are here:

Multiclient SERVER:
AutoIt         
#include <MISC.AU3> #include <String.au3> #include <ARRAY.AU3> #include <Date.AU3> HotKeySet ('!+^{ESC}','_Exit') TCPStartup () $MainSocket = TCPListen (@IPAddress1,14789,500) Dim $sckt[500 + 1][3] For $a = 0 To 500     For $b = 0 To 2         $sckt[$a][$b] = 0     Next Next While 1     _Accept ()     For $a = 1 To 500         If $sckt[$a][0] <> 0 Then             $Rcv = TCPRecv ($sckt[$a][0],1000000)             If $Rcv <> '' Then                 If $Rcv = '>>' & $sckt[$a][1] & ' Has Left The Room.' Then _DC ($sckt[$a][0])                 For $b = 1 To 500                     TCPSend ($sckt[$b][0], _NowTime () & $Rcv)                 Next             EndIf         EndIf     Next     TrayTip ('Stats','Clients=' & $sckt[0][0],5)     Sleep (10) WEnd Func _Accept ()     $SOCKET = TCPAccept ($MainSocket)     If $SOCKET = -1 then Return     For $a = 1 To 500         If $sckt[$a][0] = 0 Then             Do                 $Rcv = TCPRecv ($SOCKET,1000000)             Until $Rcv <> ''             If StringLeft ($Rcv, 4) = 'Data' Then                 $b = _StringBetween ($Rcv,'(',')')                 If Not IsArray ($b) Then                     TCPCloseSocket ($SOCKET)                     Return                 Else                     $sckt[$a][0] = $SOCKET                     $sckt[$a][1] = $b[0]                     $sckt[$a][2] = $b[1]                     $sckt[0][0] += 1                     Return                 EndIf             EndIf         EndIf     Next EndFunc Func _DC ($a)     For $b = 1 To 500         If $sckt[$b][0] <> 0 Then             If $sckt[$b][0] = $a Then                 TCPCloseSocket ($sckt[$b][0])                 $sckt[0][0] -= 1                 Return             EndIf         EndIf     Next EndFunc Func _Exit ()     For $a = 1 To 500         If $sckt[$a][0] <> 0 Then             TCPSend ($sckt[$a][0],'DC')             TCPCloseSocket ($sckt[$a][0])         EndIf     Next     TCPCloseSocket ($MainSocket)     TCPShutdown ()     Exit EndFunc


Client...
AutoIt         
#include <GUICONSTANTS.AU3> #include <WINDOWSCONSTANTS.AU3> #include <STATICCONSTANTS.AU3> #include <EDITCONSTANTS.AU3> #include <GUIEDIT.AU3> #include <MISC.AU3> #Include <WinAPI.au3> Opt ('GUIoneventmode', 1) TCPStartup () $IP = 4444 $iIP = 0 $PORT = @IPAddress1 $iPORT = 0 $Name = @UserName $SOCKET = -1 $GUI = 0 $GUI2 = 0 $C_CI = BitOR ($SS_CENTER,$SS_CENTERIMAGE) $GuiX = 700 $GuiY = 500 $sName = StringTrimRight (@ScriptName,4) $GUI = _GC ($sName,$GuiX,$GuiY,0x1) $bConnect = _GccB ('Connect',20,40,200,20) GUICtrlSetOnEvent (-1, '_Connect')     $iName = GUICtrlCreateInput ($Name,240,40,200,20,$C_CI)     GUICtrlSetBkColor (-1, 0x0)     GUICtrlSetFont (-1, 10, 400, '', 'Fixedsys')     GUICtrlSetColor (-1, 0xFFFFFF)     $bName = _GccB ('Change Name',460,40,220,20) GUICtrlSetOnEvent (-1,'_ChangeName') $Console = GUICtrlCreateEdit ('',20,70,$GuiX - 40, $GuiY - 190,BitOR($ES_MULTILINE,$WS_VSCROLL, $ES_READONLY))     GUICtrlSetColor (-1,0xFFFFFF)     GUICtrlSetBkColor (-1, 0x0)     GUICtrlSetFont (-1, 10,900,'','Tahoma')     $Input = GUICtrlCreateEdit ('',20,$GuiY - 100,$GuiX - 40, $GuiY - 420,BitOR($ES_MULTILINE,$WS_VSCROLL))     GUICtrlSetColor (-1,0xFFFFFF)     GUICtrlSetBkColor (-1, 0x0)     GUICtrlSetFont (-1, 10,900,'','Tahoma')     GUICtrlSetLimit (-1, 250,0)     While 1     If _IsPressed ('0D') And ControlGetFocus ($GUI,'') = 'Edit3' Then         $a = GUICtrlRead ($Input)         If $a <> '' And Not StringIsSpace ($a) Then _SendDATA ($a)     EndIf     If $Name = GUICtrlRead ($iName) Then         GUICtrlSetState ($bName,$GUI_DISABLE)     Else         GUICtrlSetState ($bName,$GUI_ENABLE)             EndIf     If $SOCKET <> -1 Then         $Rcv = TCPRecv ($SOCKET,1000000)         If $Rcv <> '' Then             If $Rcv = 'DC' Then                 Sleep (2000)                 WinActivate ($GUI,'')                 _Exit ()             EndIf             _GUICtrlEdit_AppendText ($Console, $Rcv)         EndIf     EndIf     Sleep (100) WEnd Func _ChangeName ()     $a = GUICtrlRead ($iName)     If $SOCKET <> -1 Then TCPSend ($SOCKET,'>>' & $Name & ' Has Changed their Name to : ' & $a & @CRLF)     $Name = $a EndFunc Func _Connect ()     If WinExists ('Connection Data','') Then Return     _GC ('Connection Data',200,140,-1)     $iIP = GUICtrlCreateInput (@IPAddress1,20,20,160,20,$C_CI)     $iPORT = GUICtrlCreateInput (14789,20,60,160,20,BitOR ($C_CI,$ES_NUMBER))     $bOK = _GccB ('Ok',20,100,70,20)     GUICtrlSetOnEvent (-1,'_ConOK')     $bCancel = _GccB ('Cancel',110,100,70,20)     GUICtrlSetOnEvent (-1,'_WinClose') EndFunc Func _ConOK ()     $IP = GUICtrlRead ($iIP)     $PORT = GUICtrlRead ($iPORT)     TCPStartup ()     WinActivate ('Connection Data','')     _WinClose ()     GUICtrlSetData ($Console,'>>Connecting :' & @CRLF & @TAB & 'IP=' & $IP & @CRLF & @TAB & 'PORT=' & $PORT & @CRLF)     For $a = 0 To 10         $SOCKET = TCPConnect ($IP,$PORT)         If $SOCKET <> -1 Then ExitLoop         TCPCloseSocket ($SOCKET)         GUICtrlSetData ($Console,StringReplace (GUICtrlRead ($Console),'>>Connecting...' & $a * 10 - 10 & '%' & @CRLF,''))         If $a = 10 Then             $a = MsgBox (5,'Error..','There has been an Error Connecting to the Server' & @CRLF & @TAB & 'ErrorCode=' & @error,'',$GUI)             Select                 Case $a = 4                     $a = 0                 Case $a = 2                     TCPCloseSocket ($SOCKET)                     TCPShutdown ()                     GUICtrlSetData ($Console,'')                     ExitLoop             EndSelect         EndIf         _GUICtrlEdit_AppendText ($Console,'>>Connecting...' & $a * 10 & '%' & @CRLF)         Sleep (100)     Next     If $a <> 2 Then         GUICtrlSetState ($bConnect,$GUI_DISABLE)         _GUICtrlEdit_AppendText ($Console,'>>Connection Complete.' & @CRLF)         TCPSend ($SOCKET,'Data(' & $Name & ')(' & @UserName & ')')         Sleep (500)         TCPSend ($SOCKET,'>>' & $Name & ' Has Joined the Room.' & @CRLF)     Else         _GUICtrlEdit_AppendText ($Console,'>>Connection Canceled.' & @CRLF)     EndIf EndFunc Func _WinClose ()     GUIDelete (WinGetHandle ('[active]','')) EndFunc Func _SendDATA ($a)     $DATA = '>>' & $Name & ' : ' & @CRLF & @TAB & StringReplace ($a,@CRLF,'') & @CRLF     If $SOCKET <> -1 Then TCPSend ($SOCKET, $DATA)     GUICtrlSetData ($Input,'')     GUICtrlSetBkColor ($Input,0x4E4E4E)     Sleep (300)     GUICtrlSetBkColor ($Input,0x0) EndFunc Func _GccB ($bText,$x,$y,$w,$h)     GUICtrlCreateLabel ('',$x,$y,$w,$h)     GUICtrlSetBkColor (-1, 0x414141)     GUICtrlSetState (-1,$GUI_DISABLE)     GUICtrlCreateLabel ('',$x,$y + $h / 2,$w,$h / 2)     GUICtrlSetBkColor (-1,0x313131)     GUICtrlSetState (-1,$GUI_DISABLE)     $a = GUICtrlCreateLabel ($bText,$x,$y,$w,$h,$C_CI)     GUICtrlSetBkColor (-1, $GUI_BKCOLOR_TRANSPARENT)     GUICtrlSetFont (-1, 10, 400, '', 'Fixedsys')     GUICtrlSetColor (-1, 0xFFFFFF)     GUICtrlSetCursor (-1, 0)     Return $a EndFunc Func _GC ($wTitle,$x,$y,$wStyle)     Select         Case $wStyle = 1 Or $wStyle = -1             $GUIStyle = BitOR($WS_DLGFRAME,$WS_POPUP, $WS_VISIBLE)             $GUIStyleEx = $WS_EX_WINDOWEDGE             If $wStyle = -1 Then $GUIStyleEx = BitOR ($GUIStyleEx, $WS_EX_TOPMOST)         Case $wStyle = 0             $GUIStyle = -1             $GUIStyleEx = -1     EndSelect     $a = GUICreate ($wTitle, $x,$y, -1, -1,$GUIStyle,$GUIStyleEx)     If $wStyle = 1 Then         GUICtrlCreateLabel ('',0,0,$GuiX,10)         GUICtrlSetBkColor (-1, 0x414141)         GUICtrlSetState (-1,$GUI_DISABLE)         GUICtrlCreateLabel ('',0,10,$GuiX,10)         GUICtrlSetBkColor (-1,0x313131)         GUICtrlSetState (-1,$GUI_DISABLE)         GUICtrlCreateLabel (WinGetTitle ($a), 40, 0, $GuiX - 40, 20, $C_CI,$GUI_WS_EX_PARENTDRAG)         GUICtrlSetBkColor (-1, $GUI_BKCOLOR_TRANSPARENT)         GUICtrlSetFont (-1, 10, 400, '', 'Fixedsys')         GUICtrlSetColor (-1, 0xFFFFFF)         GUICtrlCreateLabel ('x', 0, 0, 20, 20, $C_CI)         GUICtrlSetCursor (-1, 0)         GUICtrlSetBkColor (-1, $GUI_BKCOLOR_TRANSPARENT)         GUICtrlSetFont (-1, 10, 400, '', 'Fixedsys')         GUICtrlSetColor (-1, 0xFFFFFF)         GUICtrlSetOnEvent (-1, '_Exit')         GUICtrlCreateLabel ('_', 20, 0, 20, 20, $C_CI)         GUICtrlSetCursor (-1, 0)         GUICtrlSetBkColor (-1, $GUI_BKCOLOR_TRANSPARENT)         GUICtrlSetFont (-1, 10, 400, '', 'Fixedsys')         GUICtrlSetColor (-1, 0xFFFFFF)         GUICtrlSetOnEvent (-1, '_Minn')     EndIf     GUISetOnEvent ($GUI_EVENT_CLOSE, '_Exit', $a)     GUISetState ()     Return $a EndFunc Func _onclick ()     GUICtrlSetColor (@GUI_CtrlId,0x0)     GUICtrlSetBkColor (@GUI_CtrlId,0x4E4E4E)     Sleep (300)     GUICtrlSetColor (@GUI_CtrlId,0xFFFFFF)     GUICtrlSetBkColor (@GUI_CtrlId,$GUI_BKCOLOR_TRANSPARENT) EndFunc Func _Minn ()     _onclick ()     WinSetState ($GUI, '', @SW_MINIMIZE) EndFunc Func _Exit ()     If Not WinActive ($GUI) Then Return     TCPSend ($SOCKET, '>>' & $Name & ' Has Left The Room.' & @CRLF)     TCPCloseSocket ($SOCKET)     TCPShutdown ()     Exit EndFunc


and im currently working on :

Client-Admin status
One-Vs-one Game
Pming
Client-Disconnectotherclient
Displaypics


anyother ideas? <img src="http://www.autoitscript.com/forum/public/style_emoticons/<#EMO_DIR#>/biggrin.gif" style="vertical-align:middle" emoid=":)" border="0" alt="biggrin.gif" />

Edited by CodyBarrett, 24 October 2009 - 12:52 AM.






#2 gseller

gseller

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 1,057 posts

Posted 14 February 2009 - 03:54 AM

Very nice so far... I like the smooth way it works..

#3 CodyBarrett

CodyBarrett

    I LOVE Juicy Fruit!!!

  • Active Members
  • PipPipPipPipPipPip
  • 1,225 posts

Posted 14 February 2009 - 03:59 AM

thank you, as you can see the server disconnects the client by NAME, font&Background&Port&IP&Name&maxconnections are editable, if there are any bugs please say so.

#4 gseller

gseller

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 1,057 posts

Posted 14 February 2009 - 04:06 AM

Will do.. Thanks for sharing...

#5 CodyBarrett

CodyBarrett

    I LOVE Juicy Fruit!!!

  • Active Members
  • PipPipPipPipPipPip
  • 1,225 posts

Posted 22 February 2009 - 12:09 AM

OK i have Finished the NEW VERSION... (will upload code later on today)

Stuff added :

*Client-admin
*clients disconecting other clients
*Admin password is hardcoded in but is unuiqe for every computer
*when name changes it replaces the old name of the client in the $Clients[0][0] Array

i not at my copmuter right now will upload later today... and like always please tell if Bugs, or if you have ideas...

#6 Flamingwolf

Flamingwolf

    Wayfarer

  • Active Members
  • Pip
  • 63 posts

Posted 22 February 2009 - 01:38 AM

Can I suggest for the multiplayer game, if you don't think it will be too hard, Tetris? Blockles on I'mInLikeWithYou.com is what I'm thinking of. =]

#7 Xand3r

Xand3r

    Aka TheMadman

  • Active Members
  • PipPipPipPipPipPip
  • 454 posts

Posted 22 February 2009 - 02:46 AM

Func Broadcast($Msg)     For $i = 0 To $MaxConnections         If $Clients[$i][0] <> -1  Then TCPSend($Clients[$i][0],$Msg)     Next EndFuncƒo݊÷ ÚÈhºW[y«­¢+ÙÕ¹Œ   ɽ…‘…ÍÐ ˜ŒÀÌØí5͜¤(%½È€˜ŒÀÌØí¤€ô€ÀQ¼€˜ŒÀÌØí5…á ½¹¹•Ñ¥½¹Ì($%%˜€˜ŒÀÌØí ±¥•¹ÑÍl˜ŒÀÌØí¥ulÁt€™Ðì€À€Q¡•¸Q AM•¹ ˜ŒÀÌØí ±¥•¹ÑÍl˜ŒÀÌØí¥ulÁt°˜ŒÀÌØí5͜¤(%9•áÐ)¹‘Õ¹Œ

Only two things are infinite, the universe and human stupidity, and i'm not sure about the former -Alber EinsteinPractice makes perfect! but nobody's perfect so why practice at all?http://forum.ambrozie.ro

#8 CodyBarrett

CodyBarrett

    I LOVE Juicy Fruit!!!

  • Active Members
  • PipPipPipPipPipPip
  • 1,225 posts

Posted 22 February 2009 - 04:59 AM

huh... wow, why did i miss it... anyway ill add that.. DONE ok here is the version i abstained to upload.... ok its at the top

and uhh multilplayer, would be possible but not at the top of my list right now ill work on it, gotta find a game first..... anyway ill get to that later..

VERSION #4 IS AT THE TOP

#9 CodyBarrett

CodyBarrett

    I LOVE Juicy Fruit!!!

  • Active Members
  • PipPipPipPipPipPip
  • 1,225 posts

Posted 24 February 2009 - 09:02 PM

ERROR REPORT

the client actually cannot disconnect another client... there is an error with the $Clients[$i][0] but not sure... any help

#10 liten

liten

    Adventurer

  • Active Members
  • PipPip
  • 104 posts

Posted 15 August 2009 - 06:24 PM

ehh could you re upload code, its ehh messed up "Funny Words"
My UDF:Freeze.au3-Freeze values like CE, ML, ETC

#11 CodyBarrett

CodyBarrett

    I LOVE Juicy Fruit!!!

  • Active Members
  • PipPipPipPipPipPip
  • 1,225 posts

Posted 17 August 2009 - 02:15 AM

DID NOT update code.. just reposted it because the code was corrupted

#12 playlet

playlet

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 459 posts

Posted 17 August 2009 - 01:47 PM

and im currently working on :

Client-Admin status
One-Vs-one Game
Pming
Client-Disconnectotherclient
Displaypics

anyother ideas?


It would be nice to see a label appearing with the name of the person that is currently typing in. Like on Google Talk.

#13 CodyBarrett

CodyBarrett

    I LOVE Juicy Fruit!!!

  • Active Members
  • PipPipPipPipPipPip
  • 1,225 posts

Posted 17 August 2009 - 11:19 PM

that would be nice... but also kind of unneeded.. seeing how its a CHATROOM.. where as many people as you can handle CAN be on it... imagine 30 ppl typing at the same time... what would your Label do? flicker... OR display the last person that is typing... its possible to do this but i dont see the point

#14 playlet

playlet

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 459 posts

Posted 17 August 2009 - 11:54 PM

Good point, I forgot it's a chatroom.
Cheers, Playlet

#15 CodyBarrett

CodyBarrett

    I LOVE Juicy Fruit!!!

  • Active Members
  • PipPipPipPipPipPip
  • 1,225 posts

Posted 18 August 2009 - 02:02 AM

its a good idea... for 1 on 1 messenging... i might add that into my current chatroom project OECR... yes i have a lot XD and none of them are finished

#16 CodyBarrett

CodyBarrett

    I LOVE Juicy Fruit!!!

  • Active Members
  • PipPipPipPipPipPip
  • 1,225 posts

Posted 24 October 2009 - 12:55 AM

NEW VERSION

ALrighty... i looked through some UNfinished projects of mine.

came up with this, i took out everything that was unneeded and left the basics. its still a functioning chat (COMPLETED as far as im concerned)

but can only do these:
*logon
*change name
*send
*recv
*Disconnect on server shutdown

i changed the GUI also :)

#17 BoonPek

BoonPek

    Wayfarer

  • Active Members
  • Pip
  • 61 posts

Posted 29 December 2009 - 07:05 AM

Can you please re-post or either send me the older version with admin and stuff, I really think that that was better and nicer than the simple one.

Me and my friends tried out the latest version and it didn't work. We turned off our Firewalls and I hosted the serverin my PC. I'm the only one who can connect? Can someone here explain to me? Thanks
Posted Image




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users