Jump to content

another chat/client (up to 100 clients)


Nuffilein805
 Share

Recommended Posts

  • Replies 42
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

I am working on completely rebuilding this into a more effecient and easily upgradable and change able system that is more secure. I will post my results when finished. It will be a part of the AutoITS project. The generalized idea is from Nuffilein805 but the architecture and everything else, including complete script is from me. I just took his script, looked at it, and took the idea of a chat environment and created my own, completely different copy. I hope you are happy with my results to come B)

Talk to you later.

AutoIt Smith

Link to comment
Share on other sites

@yosemite: the kick and pm thing is just up to the clients

you can look into the code if you have a line in there (something like this)

if stringinstr($recv, "~~kick:") then

then you should have the latest version and the client has to understand what you write from the server

don't forget that clients can be spelled several ways:

client

Client

clienT

you will need the exact spelling for the commands to work

Link to comment
Share on other sites

I Wrote a different version of this server, I think it's a bit streamlined.

It's part of the AutoIt ITS project, with all adue to the original idea from nuffilein.

Official File Releases

http://codewizonline.com/autoit/viewtopic.php?t=4

I have the original idea of his server and client, and a new rewritten and beta versions + clients.

P.S. @Nuffilein, are you still a devel on our team or are you quitting? Havn't seen you on recently

Edited by AutoIt Smith
Link to comment
Share on other sites

ok, seems to be my version

tried to reproduce the error and managed to do it after about 30 mins of posting B)

you just have to delete the line at the server where it sends the userlist (usually this should not happen, but somehow it does) don't know why and got no time to investigate

should be line 114

Edited by Nuffilein805
Link to comment
Share on other sites

  • 2 months later...

@autoitsmith: i know your server is a bit different from mine although doing the same (kinda paradox)

@daliman: have you tried to remove the line?

Hi Nuffilein,

I tried your server and client and liked them. I have no interest in Internet Chat, I am interested in Intranet Chat. Mine and my wife's PCs are in different rooms on different floors. Not only that, but I have some hearing loss too. I hope to use a modified version of your server & client to communicate more directly than shouting up/down the stairs.

I added an INI file to the client so they remember the IP address and user names. The server is running on my server which only provides DNS services and supports an AutoIt script that tracks my DSL uptime.

I modified the client to write both outgoing and incoming messages to the on screen message log so you could see the dialog content. I thought it would be more useful if it POPPED to the top every time a message arrived so we would be sure to notice so I added that. I made the user list narrower so I could add acouple buttons, I plan to add a button to minimize the client and reply "Wait a minute, I'm in the middle of a thought." and another to toggle a flag on and off that will reply to any message "I've gone to the kitchen or the bathroom or I'm taking a nap." So, why am I telling you all this you ask.

I'm having a problem and I'm not sure if it was already there, or if I caused it. On my wife's PC the running client only has the INI mods. The same on my PC. I'm running the most modified version from a separate folder on my PC, its UserId is Test1, my UI is GS, my wife's UI is CS. When I send a plain message from GS it sometimes appears on CS's window, it never appears on the Test1 window. If I send a ~~pm:Test1 message it appears on the Test1 window. When I send a ~~pm:GS message from Test1 it never appears on the GS window. If I send a plain message from Test1 it sometimes appears on the CS window, but never on the GS window.

Is that clear as mud? Below is the modified version of the client script. I hope you can help me with this.

Gene

Client Code with several mods

;client for 100client-server
;made by Marten Zimmermann

#include <guiconstants.au3>
global $connect_port = 34000

$ip = ""
$ip = IniRead(@ScriptDir & "\client.ini","Server","IPaddr", "")
If $ip = "" Then
 $ip = InputBox ("IP-Adress", "Gimme the IP-Adress of the Server", @IPAddress1)
 IniWrite(@ScriptDir & "\client.ini","Server","IPaddr",$ip)
EndIf

tcpstartup()

$socket = tcpconnect ($ip, $connect_port)
if $socket = -1 then
 Exit
EndIf

Do
 Do
  $user = ""
  $user = IniRead(@ScriptDir & "\client.ini","Client","User", "")
  If $user = "" Then
   $user = InputBox ("Connected", "Connection established please type in your desired Username")
   IniWrite(@ScriptDir & "\client.ini","Client","User",$user)
  EndIf 
  if @error = 1 Then
   $end = msgbox (4, "End client", "Sure you want to exit?")
   if $end = 6 Then
    Exit
   EndIf
  EndIf
 until StringLen ($user) > 2 and StringLen ($user) < 12
 tcpsend ($socket, "~~us:" & $user)

 Do
  $recv = tcprecv ($socket, 512)
  if $recv = "~~password" Then
   $pw = InputBox ("Password required", "Please type in the password for " & $user, "", "*")
   tcpsend ($socket, "~~pw:" & $pw)
  EndIf
 until $recv = "~~accepted" or $recv = "~~rejected" or @error = 1
until $recv = "~~accepted" or $recv = "~~rejected"

if $recv = "~~rejected" Then
 msgbox (0, "Failure", "Maximum number of users reached or Server currently not availible, please try again later")
 Exit
EndIf
$CCT = "Chat Client - Connection established: " & $user
$main = GUICreate ($CCT, 500, 200)
$input = GUICtrlCreateInput ("", 10, 10, 280)
$edit = GUICtrlCreateEdit ("", 10, 40, 280, 110, $ES_READONLY + $ES_MULTILINE + $WS_VSCROLL + $ES_AUTOVSCROLL)
;$userlist = GUICtrlCreateEdit ("", 300, 10, 190, 180, $ES_READONLY + $ES_MULTILINE + $WS_VSCROLL + $ES_AUTOVSCROLL)
$userlist = GUICtrlCreateEdit ("", 300, 10, 95, 180, $ES_READONLY + $ES_MULTILINE + $WS_VSCROLL + $ES_AUTOVSCROLL)
$send = GUICtrlCreateButton ("Send", 10, 160, 280, 20, $BS_DEFPUSHBUTTON)
GUICtrlSetState ($input, $GUI_FOCUS)
GUISetState(@SW_SHOW)

while 1
 $msg = GUIGetMsg()
 if $msg = $GUI_EVENT_CLOSE Then
  $CCT = "Chat - Client shutting down in 5 seconds."
  GUICtrlSetData ($edit, $CCT)
  tcpsend ($socket, "~~bye")
  sleep (5000)
  tcpshutdown()
  Exit
 EndIf
 
; The mods just below were temporary while checking if ~~pm: could be used to force delivery/aceptance
 if $msg = $send Then
  if guictrlread ($input) <> "" Then
   If @IPAddress1 = "192.168.0.180" Then
   ;MsgBox(0,"Info.","guictrlread($input) = " & guictrlread($input) & "  " & @IPAddress1, 2)
    tcpsend ($socket, "~~pm:test1 " & guictrlread($input))
    Sleep(100)
    tcpsend ($socket, "~~pm:CS " & guictrlread($input))
   EndIf 
   If @IPAddress1 = "192.168.0.183" Then
   ;MsgBox(0,"Info.","guictrlread($input) = " & guictrlread($input) & "  " & @IPAddress1, 2)
    tcpsend ($socket, "~~pm:GS " & guictrlread($input))
    tcpsend ($socket, "~~pm:test1 " & guictrlread($input))
   EndIf 
  ;tcpsend ($socket, guictrlread($input)) 
  ;MsgBox(0,"Info.","guictrlread($input) = " & guictrlread($input))
   GUICtrlSetData ($edit, guictrlread($input) & @crlf & guictrlread ($edit))
   GUICtrlSetData ($input, "")
  EndIf
 EndIf
 
 $recv = tcprecv ($socket, 512)
 $err = @error
 
 if $recv = "~~bye" Then
  GUICtrlSetData ($edit, "~~Connection Lost" & @CRLF & GUICtrlRead($edit))
  tcpshutdown()
  ExitLoop
 EndIf
 
 if StringInStr ($recv, "~~kick:") and stringinstr($recv, $user, 1) then
  TCPSend ($socket, "~~bye")
  GUICtrlSetData ($edit, "You have been kicked!" & @crlf & guictrlread($edit))
  sleep (2000)
  TCPShutdown()
  ExitLoop
 EndIf
 
 $priv = 0
 if StringInStr ($recv, "~~pm:") and stringinstr($recv, $user) then
  $user1 = $user & " "
  if StringInStr ($recv, $user1) Then
   $recv = StringReplace ($recv, "~~pm:", "", 1)
   $recv = StringReplace ($recv, $user & " ", "", 1)
   GUICtrlSetData ($edit, $recv & " (private)" & @crlf & guictrlread($edit))
   WinSetOnTop ( "Chat Client - Connection established: " & $user, "", 1 )
   WinActivate ( "Chat Client - Connection established: " & $user)
   Sleep(200)
   WinSetOnTop ( "Chat Client - Connection established: " & $user, "", 0 )
   $priv = 1
  EndIf
 EndIf
   
 if stringinstr ($recv, "~~accepted") then
  $recv = ""
 EndIf
 
 if $recv <> "" and $err = 0 and not StringInStr ($recv, "~~users:") and not StringInStr ($recv, "~~accepted") and not StringInStr($recv, "~~pm:") and not stringinstr($recv, "~~kick:") and $priv = 0 Then
  GUICtrlSetData ($edit, $recv & @CRLF & GUICtrlRead($edit))
  WinSetOnTop ( "Chat Client - Connection established: " & $user, "", 1 )
  WinActivate ( "Chat Client - Connection established: " & $user)
  Sleep(200)
  WinSetOnTop ( "Chat Client - Connection established: " & $user, "", 0 )
 EndIf
 
 if StringInStr($recv, "~~users:") then
  $users = StringTrimLeft ($recv, 8)
  $users = StringReplace ($users, "|", @crlf)
  GUICtrlSetData ($userlist, $users)
 EndIf
 
WEnd


Func OnAutoItExit()
 $CCT = "Chat - Client shutting down."
 GUICtrlSetData ($edit, $CCT & @CRLF & GUICtrlRead($edit))
 TCPSend( $socket, "~~bye" )
 TCPCloseSocket( $socket )
 TCPShutDown()
EndFunc

[font="Verdana"]Thanks for the response.Gene[/font]Yes, I know the punctuation is not right...

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...