themax90 Posted November 10, 2005 Share Posted November 10, 2005 (edited) Hello all! I have just finished writing most parts of my chat server/client environment. It currently supports Registration Login Personal Messages Userlists StringEncryption And similar features. Here are the au3 files: FILES REMOVED The client requires this picture: FILES REMOVED The server requires this include file: FILES REMOVED Save the picture as Logo.jpg in the file folder of the client and save the include file as AddedFuncs.au3 in the server file folder. Please do not forget it is written in AutoIt v3.1.1.87 beta. It works like MOST TCP servers do. Start the server, have the client connect to the Ip Address and port. The server and client is fully customizable in the Encryption levels and passwords, along with max. users, and server port. I hope you all like. Also, one thing, you cannot run this behind a router unless you forward the port you are using. If you do not know what ports are avialible to host off of goto Official AutoIt ITS File Releases(see signature) and download the Home Computer and PublicIp TCP Port Tester utility at the end of the post. Those who wish to download it via autoitscript.com servers, here is the attachments. FILES REMOVED Run the home computer first, it will tell you what your personal computer has blocked, it takes about 5 minutes. Then, if you wish to host this server for a longer majority of the time, run PublicIp tester, it takes anywhere from 30 minutes to 3 hours depending on connection speed and computer speed but it is recommended if you are going to run this for a sustained amount of time(week or more) I am running a server on my computer at the Ip Address of REMOVED on port REMOVED if you would like to connect. I am open to all feedback and thoughts AutoIt Smith P.S. Please do not comment about my server scenarios, I know I when overboard with some useless code. Hehe, but I like having all possible scenarios coded to tell if there is an error. Edited November 11, 2005 by AutoIt Smith Link to comment Share on other sites More sharing options...
poisonkiller Posted November 10, 2005 Share Posted November 10, 2005 (edited) Do you know, is it working with 3.1.1.84 version too? I runned client and it said something about missing .ini and then i get error: Line 186 (File "C:\WINDOWS\Desktop\Client.au3"): Dim $User[ ($AoU = 1) ] Dim $User[ ^ERROR Error: Array variable subscript badly formatted. Maybe is it your mistake or my AutoIt is too old? Oh... And its writing me every time empty Chat.ini file. Edited November 10, 2005 by poisonkiller Link to comment Share on other sites More sharing options...
themax90 Posted November 10, 2005 Author Share Posted November 10, 2005 (edited) I am not sure but I got that ALOT with verison 3.1.1.84, and that is not correct, the line should be Dim $User[ ($AoU + 1) ] Here is the client script: expandcollapse popup#include <GuiConstants.au3> #include <Array.au3> #include <String.au3> Dim $ChatIni = "Chat.ini", $MaxChar = 512000, $EncryptPw = "Fudge", $EncryptLvl = "2", $MainSocket = -1 $LogonGUI = GUICreate("ITS Chat", 210, 325, (@DesktopWidth - 210) / 2, (@DesktopHeight - 325) / 2) $FileMenu = GUICtrlCreateMenu("File") $ServerSettings = GUICtrlCreateMenuItem("Server Settings", $FileMenu, 0) $Exit = GUICtrlCreateMenuItem("Exit", $FileMenu, 1) $ChatLogo = GUICtrlCreatePic("Logo.jpg", 10, 10, 190, 155) $Usernames = GUICtrlCreateCombo("", 10, 200, 190, 21) $Password = GUICtrlCreateInput("", 10, 250, 190, 20) $UserLabel = GUICtrlCreateLabel("Username:", 72.5, 177.5, 60, 15, $SS_SUNKEN) $PassLabel = GUICtrlCreateLabel("Password:", 72.5, 227.5, 60, 15, $SS_SUNKEN) $Register = GUICtrlCreateButton("Register", 10, 280, 100, 20) $Logon = GUICtrlCreateButton("Logon", 120, 280, 80, 20) GUISetState() LoadSettings($ChatIni) While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE Or $msg = $Exit ExitLoop Case $msg = $ServerSettings $ServerSetGUI = GUICreate("Server Settings", 130, 155, (@DesktopWidth - 130) / 2, (@DesktopHeight - 155) / 2) $IpSet = GUICtrlCreateInput("", 10, 40, 110, 20) $IpSetLabel = GUICtrlCreateLabel("Server Ip Address", 20, 10, 90, 20) $PortSet = GUICtrlCreateInput("", 10, 100, 110, 20) $PortSetLabel = GUICtrlCreateLabel("Server Port Number", 20, 70, 100, 20) $SetOpts = GUICtrlCreateButton("Set Options", 20, 130, 90, 20) GUISetState() While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $SetOpts $IpIniSet = GUICtrlRead($IpSet) $PortIniSet = GUICtrlRead($PortSet) IniWrite($ChatIni, "Server Settings", "Server", $IpIniSet) IniWrite($ChatIni, "Server Settings", "Port", $PortIniSet) MsgBox(0, "Set", "Your server settings as been set to the following, IpAddress " & $IpIniSet & " Port " & $PortIniSet) ExitLoop Case Else ;;; EndSelect WEnd GUIDelete($ServerSetGUI) Case $msg = $Register ; Register On Server $RegisterGUI = GUICreate("Register", 170, 140, (@DesktopWidth - 170) / 2, (@DesktopHeight - 140) / 2) $UL = GUICtrlCreateLabel("Username:", 60, 10, 63, 15) $UserInput = GUICtrlCreateInput("", 10, 30, 150, 20) $PL = GUICtrlCreateLabel("Password:", 60, 60, 50, 15) $PassInput = GUICtrlCreateInput("", 10, 80, 150, 20) $RegGo = GUICtrlCreateButton("Register", 50, 110, 70, 20) GUISetState() While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE Or $msg = $Exit ExitLoop Case $msg = $RegGo TCPStartup() GUISetState(@SW_HIDE, $RegisterGUI) $UserSend = GUICtrlRead($UserInput) $PassSend = GUICtrlRead($PassInput) $Server = IniRead($ChatIni, "Server Settings", "Server", -1) $Port = IniRead($ChatIni, "Server Settings", "Port", -1) $MainSocket = TCPConnect($Server, $Port) $StatusGUI = GUICreate("Status", 270, 260, (@DesktopWidth - 270) / 2, (@DesktopHeight - 260) / 2) $Status = GUICtrlCreateEdit("", 10, 10, 250, 200, $ES_READONLY + $WS_VSCROLL + $ES_AUTOVSCROLL) $Close = GUICtrlCreateButton("Close", 80, 220, 110, 30) GUISetState() $Text = "~register-" & $UserSend & "-" & $PassSend SendMessage($Text) If $MainSocket = -1 Then GUICtrlSetData($Status, "Unable to connect to server.....") EndIf While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE Or $msg = $Close ExitLoop Case Else ;;; EndSelect $Recv = TCPRecv($MainSocket, $MaxChar) $Recv = _StringEncrypt(0, $Recv, $EncryptPw, $EncryptLvl) If $Recv <> "" And $Recv <> "~bye" Then GUICtrlSetData($Status, GUICtrlRead($Status) & $Recv) ElseIf $Recv <> "" And $Recv = "~bye" Then TCPCloseSocket($MainSocket) TCPShutdown() EndIf WEnd GUIDelete($StatusGUI) ExitLoop Case Else ;;; EndSelect WEnd GUIDelete($RegisterGUI) Case $msg = $Logon ; Logon On Server $ChatGUI = GUICreate("ITS Chat", 410, 290, (@DesktopWidth - 410) / 2, (@DesktopHeight - 270) / 2) $ChatFileMenu = GUICtrlCreateMenu("File") $ChatClose = GUICtrlCreateMenuItem("Close Connection", $ChatFileMenu, 0) $History = GUICtrlCreateEdit("", 10, 10, 290, 170, $ES_AUTOVSCROLL + $WS_VSCROLL + $ES_READONLY) $Userlist = GUICtrlCreateList("", 310, 10, 90, 170) $Message = GUICtrlCreateEdit("", 10, 190, 290, 70, $ES_AUTOVSCROLL + $WS_VSCROLL) $Send = GUICtrlCreateButton("Send", 310, 230, 90, 30) $PersonalSend = GUICtrlCreateButton("Send To User", 310, 190, 90, 30) GUISetState() $UserLogon = GUICtrlRead($Usernames) $PassLogon = GUICtrlRead($Password) GUISetState(@SW_HIDE, $LogonGUI) TCPStartup() $Server = IniRead($ChatIni, "Server Settings", "Server", -1) $Port = IniRead($ChatIni, "Server Settings", "Port", -1) $MainSocket = TCPConnect($Server, $Port) If $MainSocket = -1 Then GUICtrlSetData($History, "Unable to connect to server........") EndIf $Text = "~login-" & $UserLogon & "-" & $PassLogon SendMessage($Text) While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE Or $msg = $ChatClose $Text = "~bye" SendMessage($Text) ExitLoop Case $msg = $Send ; Send Message $Text = GUICtrlRead($Message) GUICtrlSetData($Message, "") SendMessage($Text) Case $msg = $PersonalSend $PmUser = GUICtrlRead($Userlist) $PmText = GUICtrlRead($Message) GUICtrlSetData($Message, "") SendMessage("~pm-" & $PmUser & "-" & $PmText) Case Else ;;; EndSelect $MainRecv = TCPRecv($MainSocket, $MaxChar) $MainRecv = _StringEncrypt(0, $MainRecv, $EncryptPw, $EncryptLvl) $UserListCheck = StringSplit($MainRecv, "-") Select Case $MainRecv <> "" And $MainRecv <> "~bye" And $UserListCheck[1] <> "~userlist" GUICtrlSetData($History, GUICtrlRead($History) & @CRLF & $MainRecv) Case $MainRecv = "~bye" ; Connection was closed. Case $UserListCheck[1] = "~userlist" ; Userlist was sent. GUICtrlSetData($Userlist, $UserListCheck[2]) Case Else ; None EndSelect WEnd GUIDelete($ChatGUI) TCPCloseSocket($MainSocket) TCPShutdown() GUISetState(@SW_SHOW, $LogonGUI) Case Else ;;; EndSelect WEnd Exit Func LoadSettings($Ini) $IniExists = FileExists($Ini) If $IniExists = 0 Then ; Ini Does Not Exist FileOpen($Ini, 2) FileClose($Ini) IniWrite($Ini, "Users", "0", "") IniWrite($Ini, "Users", "Amount", "0") IniWrite($Ini, "Server Settings", "Server", "") IniWrite($Ini, "Server Settings", "Port", "") MsgBox(0, "No Ini Detected", "ITS Chat did not detect an Ini file and one was generated for you." & @CRLF & "Please set all settings under the File menu before operating.") ElseIf $IniExists Then ; Ini Does Exist EndIf $AoU = IniRead($Ini, "Users", "Amount", -1) Dim $User[ ($AoU + 1) ] $Track = 0 For $Track = 0 To $AoU Step 1 $User[$Track] = IniRead($Ini, "Users", $Track, -1) Next _ArraySort($User) For $Track = 0 To $AoU Step 1 GUICtrlSetData($Usernames, $User[$Track], $User[0]) Next EndFunc ;==>LoadSettings Func Error($ErrorNum = -1) Select Case $ErrorNum = 0 ; Unknown Internal Error MsgBox(0, "Error", "Unknown Internal Error") Case $ErrorNum = 1 ; Corrupt Ini MsgBox(0, "Error", "Corrupt Ini") Case Else ; Unknown Error MsgBox(0, "Error", "Unknown Error") EndSelect Exit EndFunc ;==>Error Func SendMessage($Text) $Text = _StringEncrypt(1, $Text, $EncryptPw, $EncryptLvl) TCPSend($MainSocket, $Text) Endfunc Func OnAutoItExit() If $MainSocket <> -1 Then SendMessage("~bye") TCPCloseSocket($MainSocket) EndIf TCPShutdown() EndFunc Please try logging into my server at 71.56.132.184 port 8000 so I can see if it works on my connection. I hope this works for you. Chat.Ini should be on your desktop next to your Client.au3. If it's not I do not understand what is wrong. The code is fine, try updating if this code (above) does not work. Edit 1 : Incase the Ini does not completely initialize or somethings wrong with your copy of AutoIt, or if you still get the Ini MsgBox EVERY time you start the script then use the following Ini Save it as Chat.ini [Users] 0= Amount=0 [Server Settings] Server=71.56.132.184 Port=8000 Those are the settings to connect to my running server. Edit 2 : Just incase your script STILL does not work here is an excutable, just unzip it. Edited November 10, 2005 by AutoIt Smith Link to comment Share on other sites More sharing options...
theguy0000 Posted November 10, 2005 Share Posted November 10, 2005 I get an "Unknown Internal Error" when I start up the server. The cake is a lie.www.theguy0000.com is currentlyUP images.theguy0000.com is currentlyUP all other *.theguy0000.com sites are DOWN Link to comment Share on other sites More sharing options...
JRSmile Posted November 10, 2005 Share Posted November 10, 2005 (edited) i got that too, changed $MyIp in the server.au3 from _GetIP() to 127.0.0.1 for testing... then it worked.. Edited November 10, 2005 by JRSmile $a=StringSplit("547275737420796F757220546563686E6F6C75737421","") For $b=1 To UBound($a)+(-1*-1*-1)step(2^4/8);&$b+=1*2/40*µ&Asc(4) Assign("c",Eval("c")&Chr(Dec($a[$b]&$a[$b+1])));''Chr("a")&"HI" Next ;time_U&r34d,ths,U-may=get$the&c.l.u.e;b3st-regards,JRSmile; MsgBox(0x000000,"",Eval("c"));PiEs:d0nt+*b3.s4d.4ft3r.1st-try:-) Link to comment Share on other sites More sharing options...
theguy0000 Posted November 10, 2005 Share Posted November 10, 2005 it looks like I need a "Master.ini" file... The cake is a lie.www.theguy0000.com is currentlyUP images.theguy0000.com is currentlyUP all other *.theguy0000.com sites are DOWN Link to comment Share on other sites More sharing options...
GaryFrost Posted November 10, 2005 Share Posted November 10, 2005 If your behind a router you'll either need to forward the port or just for testing purposes change the $MyIp to 127.0.0.1. Once the server gets a good start it creates the Master.ini. SciTE for AutoItDirections for Submitting Standard UDFs  Don't argue with an idiot; people watching may not be able to tell the difference.  Link to comment Share on other sites More sharing options...
themax90 Posted November 10, 2005 Author Share Posted November 10, 2005 (edited) Ok quick explaination. If you are behind a router or the port you wish to load off of is blocked, you cannot start the server therefore it faults and will not continue to load. You will get the Unknown Internal Error. However, with the proper port forwarded it should be no problem. I will go into testing on if the 127.0.0.1 basic network ip will work for starting up these servers.AutoIt SmithEdit 1: Just tested on the default network 127.0.0.1 and no client can connect to the actual Ip Address, only 127.0.0.1, which is default for every computer. Therefore I have concluded you must use your actual Ip. One more reason you my have gotten Internal Error is _GetIp returned something that was not an Ip Address. For example, if you are behind multiple routers, have a firewall, do not actually have an internet connection, or the _GetIp function failed, then it will return a non Ip integer to your $MyIp variable, which causes the fault. If _GetIp does not work then you can manually goto http://www.whatismyip.org/ and paste you ip address in the $MyIp variable and it should work. However if you still get an Internal Error then it must be one of the following problems.(From highest probability to absolute lowest, 1 High, 4 Low)1. You are behind a router system without the port/s forwarded.2. You have a firewall blocking internet access and TCP control.3. The Ip Address was invalid.4. You do not have an actual internet connection. Edited November 10, 2005 by AutoIt Smith Link to comment Share on other sites More sharing options...
theguy0000 Posted November 11, 2005 Share Posted November 11, 2005 (edited) the homeIPTester said I have all ports allowed. ill change my ip to 127.0.0.1 then and see what it does edit: ...how long does it usually take to connect? Ive had the client trying to register me for the last 2 or 3 mins and the status screen is blank... Edited November 11, 2005 by theguy0000 The cake is a lie.www.theguy0000.com is currentlyUP images.theguy0000.com is currentlyUP all other *.theguy0000.com sites are DOWN Link to comment Share on other sites More sharing options...
themax90 Posted November 11, 2005 Author Share Posted November 11, 2005 (edited) This has been Fixed and Updated Here:http://codewizonline.com/autoit/viewtopic.php?t=23Now works seamlessly over internetEdit 1 : Sorry my server crashed at 4:38 if someone was trying to connect. Edited November 12, 2005 by AutoIt Smith Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now