JohnBailey Posted August 8, 2007 Share Posted August 8, 2007 This thread originated out of http://www.autoitscript.com/forum/index.ph...mp;#entry385532Hostage, I don't know what ADOR is. I found this - http://msdn2.microsoft.com/en-us/library/ms681510.aspx - but it doesn't really clarify things When I used the script you posted (thanks btw), I got the following errors. Obviously it's because there are undefined functions and variables. However, I'm not sure what to create because I don't know what ADOR is or what you had setup.Auto-It files\Experiments\my projects\custom server 2.au3(22,47) : WARNING: $adInteger: possibly used before declaration. $fwpsrv_sockets.fields.append("ID", $adInteger) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ Auto-It files\Experiments\my projects\custom server 2.au3(23,52) : WARNING: $adVarWChar: possibly used before declaration. $fwpsrv_sockets.fields.append("Socket", $adVarWChar, ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ Auto-It files\Experiments\my projects\custom server 2.au3(55,35) : WARNING: $adOpenKeyset: possibly used before declaration. $Rs.cursortype = $adOpenKeyset ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ Auto-It files\Experiments\my projects\custom server 2.au3(56,37) : WARNING: $adLockOptimistic: possibly used before declaration. $rs.locktype = $adLockOptimistic ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ Auto-It files\Experiments\my projects\custom server 2.au3(59,102) : WARNING: $newCon: possibly used before declaration. $rs.Open("SELECT * FROM [Alerts] WHERE [User] = '" & $user & "' AND [Dismissed] IS NULL", $newCon) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~^ Auto-It files\Experiments\my projects\custom server 2.au3(22,47) : ERROR: $adInteger: undeclared global variable. $fwpsrv_sockets.fields.append("ID", $adInteger) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ Auto-It files\Experiments\my projects\custom server 2.au3(41,42) : ERROR: FWP_Log(): undefined function. FWP_Log("Global message: " & $message) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ Auto-It files\Experiments\my projects\custom server 2.au3(97,75) : ERROR: UserFromId(): undefined function. $fwpsrv_sockets.fieldS("User Name") = UserFromId($read_user_id) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ Auto-It files\Experiments\my projects\custom server 2.au3 - 3 error(s), 5 warning(s) A decision is a powerful thing Link to comment Share on other sites More sharing options...
JohnBailey Posted August 8, 2007 Author Share Posted August 8, 2007 basically, I'm just wanting to build a list of users logged into the app A decision is a powerful thing Link to comment Share on other sites More sharing options...
Hostage Posted August 8, 2007 Share Posted August 8, 2007 An ADOR.recordset is a recordset which is disconnected from any database.The variables you are missing are constants that are needed if you use the Jet database provider (usually to connect to an MS Access database or a text file). I've also had no problems using them on SQL Server.Here is my include file for them:ADO Constants.au3expandcollapse popup#include-once ;---- CursorType Values ---- $adOpenForwardOnly = 0 $adOpenKeyset = 1 $adOpenDynamic = 2 $adOpenStatic = 3 ;---- CursorOptionEnum Values ---- $adHoldRecords = 0x00000100 $adMovePrevious = 0x00000200 $adAddNew = 0x01000400 $adDelete = 0x01000800 $adUpdate = 0x01008000 $adBookmark = 0x00002000 $adApproxPosition = 0x00004000 $adUpdateBatch = 0x00010000 $adResync = 0x00020000 $adNotify = 0x00040000 ;---- LockTypeEnum Values ---- $adLockReadOnly = 1 $adLockPessimistic = 2 $adLockOptimistic = 3 $adLockBatchOptimistic = 4 ;---- ExecuteOptionEnum Values ---- $adRunAsync = 0x00000010 ;---- ObjectStateEnum Values ---- $adStateClosed = 0x00000000 $adStateOpen = 0x00000001 $adStateConnecting = 0x00000002 $adStateExecuting = 0x00000004 ;---- CursorLocationEnum Values ---- $adUseServer = 2 $adUseClient = 3 ;---- DataTypeEnum Values ---- $adEmpty = 0 $adTinyInt = 16 $adSmallInt = 2 $adInteger = 3 $adBigInt = 20 $adUnsignedTinyInt = 17 $adUnsignedSmallInt = 18 $adUnsignedInt = 19 $adUnsignedBigInt = 21 $adSingle = 4 $adDouble = 5 $adCurrency = 6 $adDecimal = 14 $adNumeric = 131 $adBoolean = 11 $adError = 10 $adUserDefined = 132 $adVariant = 12 $adIDispatch = 9 $adIUnknown = 13 $adGUID = 72 $adDate = 7 $adDBDate = 133 $adDBTime = 134 $adDBTimeStamp = 135 $adBSTR = 8 $adChar = 129 $adVarChar = 200 $adLongVarChar = 201 $adWChar = 130 $adVarWChar = 202 $adLongVarWChar = 203 $adBinary = 128 $adVarBinary = 204 $adLongVarBinary = 205 ;---- FieldAttributeEnum Values ---- $adFldMayDefer = 0x00000002 $adFldUpdatable = 0x00000004 $adFldUnknownUpdatable = 0x00000008 $adFldFixed = 0x00000010 $adFldIsNullable = 0x00000020 $adFldMayBeNull = 0x00000040 $adFldLong = 0x00000080 $adFldRowID = 0x00000100 $adFldRowVersion = 0x00000200 $adFldCacheDeferred = 0x00001000 ;---- EditModeEnum Values ---- $adEditNone = 0x0000 $adEditInProgress = 0x0001 $adEditAdd = 0x0002 $adEditDelete = 0x0004 ;---- RecordStatusEnum Values ---- $adRecOK = 0x0000000 $adRecNew = 0x0000001 $adRecModified = 0x0000002 $adRecDeleted = 0x0000004 $adRecUnmodified = 0x0000008 $adRecInvalid = 0x0000010 $adRecMultipleChanges = 0x0000040 $adRecPendingChanges = 0x0000080 $adRecCanceled = 0x0000100 $adRecCantRelease = 0x0000400 $adRecConcurrencyViolation = 0x0000800 $adRecIntegrityViolation = 0x0001000 $adRecMaxChangesExceeded = 0x0002000 $adRecObjectOpen = 0x0004000 $adRecOutOfMemory = 0x0008000 $adRecPermissionDenied = 0x0010000 $adRecSchemaViolation = 0x0020000 $adRecDBDeleted = 0x0040000 ;---- GetRowsOptionEnum Values ---- $adGetRowsRest = -1 ;---- PositionEnum Values ---- $adPosUnknown = -1 $adPosBOF = -2 $adPosEOF = -3 ;---- enum Values ---- $adBookmarkCurrent = 0 $adBookmarkFirst = 1 $adBookmarkLast = 2 ;---- MarshalOptionsEnum Values ---- $adMarshalAll = 0 $adMarshalModifiedOnly = 1 ;---- AffectEnum Values ---- $adAffectCurrent = 1 $adAffectGroup = 2 $adAffectAll = 3 ;---- FilterGroupEnum Values ---- $adFilterNone = 0 $adFilterPendingRecords = 1 $adFilterAffectedRecords = 2 $adFilterFetchedRecords = 3 $adFilterPredicate = 4 ;---- SearchDirection Values ---- $adSearchForward = 1 $adSearchBackward = -1 ;---- ConnectPromptEnum Values ---- $adPromptAlways = 1 $adPromptComplete = 2 $adPromptCompleteRequired = 3 $adPromptNever = 4 ;---- ConnectModeEnum Values ---- $adModeUnknown = 0 $adModeRead = 1 $adModeWrite = 2 $adModeReadWrite = 3 $adModeShareDenyRead = 4 $adModeShareDenyWrite = 8 $adModeShareExclusive = 0xc $adModeShareDenyNone = 0x10 ;---- IsolationLevelEnum Values ---- $adXactUnspecified = 0xffffffff $adXactChaos = 0x00000010 $adXactReadUncommitted = 0x00000100 $adXactBrowse = 0x00000100 $adXactCursorStability = 0x00001000 $adXactReadCommitted = 0x00001000 $adXactRepeatableRead = 0x00010000 $adXactSerializable = 0x00100000 $adXactIsolated = 0x00100000 ;---- XactAttributeEnum Values ---- $adXactCommitRetaining = 0x00020000 $adXactAbortRetaining = 0x00040000 ;---- PropertyAttributesEnum Values ---- $adPropNotSupported = 0x0000 $adPropRequired = 0x0001 $adPropOptional = 0x0002 $adPropRead = 0x0200 $adPropWrite = 0x0400 ;---- ErrorValueEnum Values ---- $adErrInvalidArgument = 0xbb9 $adErrNoCurrentRecord = 0xbcd $adErrIllegalOperation = 0xc93 $adErrInTransaction = 0xcae $adErrFeatureNotAvailable = 0xcb3 $adErrItemNotFound = 0xcc1 $adErrObjectInCollection = 0xd27 $adErrObjectNotSet = 0xd5c $adErrDataConversion = 0xd5d $adErrObjectClosed = 0xe78 $adErrObjectOpen = 0xe79 $adErrProviderNotFound = 0xe7a $adErrBoundToCommand = 0xe7b $adErrInvalidParamInfo = 0xe7c $adErrInvalidConnection = 0xe7d $adErrStillExecuting = 0xe7f $adErrStillConnecting = 0xe81 ;---- ParameterAttributesEnum Values ---- $adParamSigned = 0x0010 $adParamNullable = 0x0040 $adParamLong = 0x0080 ;---- ParameterDirectionEnum Values ---- $adParamUnknown = 0x0000 $adParamInput = 0x0001 $adParamOutput = 0x0002 $adParamInputOutput = 0x0003 $adParamReturnValue = 0x0004 ;---- CommandTypeEnum Values ---- $adCmdUnknown = 0x0008 $adCmdText = 0x0001 $adCmdTable = 0x0002 $adCmdStoredProc = 0x0004 ;---- SchemaEnum Values ---- $adSchemaProviderSpecific = -1 $adSchemaAsserts = 0 $adSchemaCatalogs = 1 $adSchemaCharacterSets = 2 $adSchemaCollations = 3 $adSchemaColumns = 4 $adSchemaCheckraints = 5 $adSchemaraintColumnUsage = 6 $adSchemaraintTableUsage = 7 $adSchemaKeyColumnUsage = 8 $adSchemaReferentialContraints = 9 $adSchemaTableraints = 10 $adSchemaColumnsDomainUsage = 11 $adSchemaIndexes = 12 $adSchemaColumnPrivileges = 13 $adSchemaTablePrivileges = 14 $adSchemaUsagePrivileges = 15 $adSchemaProcedures = 16 $adSchemaSchemata = 17 $adSchemaSQLLanguages = 18 $adSchemaStatistics = 19 $adSchemaTables = 20 $adSchemaTranslations = 21 $adSchemaProviderTypes = 22 $adSchemaViews = 23 $adSchemaViewColumnUsage = 24 $adSchemaViewTableUsage = 25 $adSchemaProcedureParameters = 26 $adSchemaForeignKeys = 27 $adSchemaPrimaryKeys = 28 $adSchemaProcedureColumns = 29You can use any of the normal ADO recordset methods on an ADOR recordset:ADO RecordsetI like them better than arrays for this type of project.I'll put together a functioning server/client that you can see and put it up in a bit. Link to comment Share on other sites More sharing options...
JohnBailey Posted August 8, 2007 Author Share Posted August 8, 2007 ADO RecordsetAWESOME!I'll put together a functioning server/client that you can see and put it up in a bit.AWESOME!! I look forward to seeing it I'm trying to learn this stuff, but usually the examples are so intense that I get overwhelmed, especially since I'm just looking for the basics. A decision is a powerful thing Link to comment Share on other sites More sharing options...
Hostage Posted August 8, 2007 Share Posted August 8, 2007 Here I think this will do it. I stripped out all of the functions for my business. It isn't really documented, so if you have any questions feel free to ask. You'll need the files in the zip as well. Server.au3 expandcollapse popup$oMyError = ObjEvent("AutoIt.Error", "MyErrFunc") TraySetIcon("shell32.dll", -18) ;includes #include <ado Constants.au3> #include <guiconstants.au3> #include <GUIListview.au3> #include <date.au3> #include <globals.au3> $version = "2.0" Func MyErrFunc() if @compiled = 0 then Msgbox(0,"Error","We intercepted a COM Error !" & @CRLF & @CRLF & _ "err.description is: " & @TAB & $oMyError.description & @CRLF & _ "err.windescription:" & @TAB & $oMyError.windescription & @CRLF & _ "err.number is: " & @TAB & hex($oMyError.number,8) & @CRLF & _ "err.lastdllerror is: " & @TAB & $oMyError.lastdllerror & @CRLF & _ "err.scriptline is: " & @TAB & $oMyError.scriptline & @CRLF & _ "err.source is: " & @TAB & $oMyError.source & @CRLF & _ "err.helpfile is: " & @TAB & $oMyError.helpfile & @CRLF & _ "err.helpcontext is: " & @TAB & $oMyError.helpcontext _ ) else $text = $oMyError.scriptline & ": " & $oMyError.source & ": " & $oMyError.description filewriteline("Errors Server 2.txt", $text) endif SetError(1) ; to check for after this function returns EndFunc Func FWP_Log($text) $text = _datetimeformat(_nowcalcdate(), 2) & "|" & _datetimeformat(_nowcalc(), 4) & "|" & $text _guictrllistviewinsertItem($gui_status_listview, 0, $text) for $loop1=0 to 1 _GUICtrlListViewSetColumnWidth($gui_status_listview, $loop1, $LVSCW_AUTOSIZE) Next _GUICtrlListViewSetColumnWidth($gui_status_listview, $loop1, $LVSCW_AUTOSIZE_useheader) endfunc Func FWP_TCP_Check() ;check for new connections $temp = TCPAccept($fwpsrv_MainSocket) if $temp <> -1 Then $read_user_id = TCPRecv($temp, 255) if stringinstr($read_user_id, "FWP:") Then $read_user_id = stringreplace($read_user_id, "FWP:", "") endif ;add to recordset $fwpsrv_sockets_id += 1 $fwpsrv_sockets_count += 1 $fwpsrv_Sockets.AddNew $fwpsrv_sockets.fields("ID") = $fwpsrv_sockets_id $fwpsrv_sockets.fieldS("Socket") = $temp ;~ $fwpsrv_sockets.fieldS("User ID") = $read_user_id $fwpsrv_sockets.fieldS("User Name") = $read_user_id $fwpsrv_sockets.fieldS("Timer") = timerinit() ;send back read user id for confirmation to client TCPSend($fwpsrv_sockets.fieldS("Socket").value, "FWP:" & $read_user_id) FWP_Log("Connection from " & $fwpsrv_sockets.fields("User Name").value & " on socket " & $temp) endif ;check existing connections if $fwpsrv_sockets_count > 0 then $fwpsrv_sockets.MoveFirst while not $fwpsrv_sockets.EOF ;check for waiting data $temp = TCPRecv($fwpsrv_sockets.fields("Socket").value, 255) if $temp <> "" Then $user = $fwpsrv_sockets.fields("User Name").value if $temp = "Ping" then TCPSend($fwpsrv_sockets.fields("Socket").value, "Pong") Else FWP_log($user & ": Sent following:" & $temp) endif $fwpsrv_sockets.fieldS("Timer") = timerinit() endif ;check for time-out and delete $time = timerdiff($fwpsrv_sockets.fields("Timer").value)/1000 if $time > 30 Then ;delete FWP_Log("Connection dropped from " & $fwpsrv_sockets.fields("User Name").value & " on socket " & $fwpsrv_sockets.fields("Socket").value) $fwpsrv_sockets.Delete $fwpsrv_sockets_count -= 1 endif $fwpsrv_sockets.MoveNext WEnd endif endfunc Func FWP_Events() FWP_TCP_Check() endfunc Func FWP_UpdateSocketsListView($sockets_listview) _GUICtrlListViewDeleteAllItems($sockets_listview) if $fwpsrv_sockets_count > 0 then $fwpsrv_sockets.MoveFirst $count = 0 while not $fwpsrv_sockets.EOF $text = $fwpsrv_sockets.fields("Socket").value & "|" $text &= round(TimerDiff($fwpsrv_sockets.fields("Timer").value)/1000, 0) & "|" $text &= $fwpsrv_sockets.fields("User ID").value & "|" $text &= $fwpsrv_sockets.fields("User Name").value & "|" $count += 1 _guictrllistviewinsertitem($sockets_listview, $count-1, $text) $fwpsrv_sockets.MoveNext wend for $loop1=0 to _GUICtrlListViewGetSubItemsCount($sockets_listview) - 1 _GUICtrlListViewSetColumnWidth($sockets_listview, $loop1, $LVSCW_AUTOSIZE) next _GUICtrlListViewSetColumnWidth($sockets_listview, $loop1, $LVSCW_AUTOSIZE_useheader) EndIf endfunc Func Main() $text = "FWP Server " & $version $gui = GUICreate($text, 10, 10, -1, -1,BitOr($GUI_SS_DEFAULT_GUI, $ws_sizebox, $ws_maximize)) ;~ GUISetBkColor($wm_guibgcolor) WinSetState($gui, "", @sw_maximize) $temp = WinGetPos($gui) Opt("WinTitleMatchMode", 4) $temp2 = WinGetPos("classname=Shell_TrayWnd") if @error = 1 Then else ;~ winmove($gui, "", $temp[0], $temp[1], $temp[2], $temp[3]-$temp2[3]) EndIf Opt("WinTitleMatchMode", 1) $gui_width = $temp[2] $gui_height = $temp[3]-$temp2[3]-35 $gui_status_listview = guictrlcreatelistview("Date|Time|Description", 20, 20, $gui_width-40, $gui_height-250) $top = $gui_height - 230 $sockets_listview = guictrlcreatelistview("Socket|Idle Time|User ID|User", 20, $top, $gui_width - 40, 200) $last_fwpsrv_sockets_count = 0 while 1=1 ;check gui $msg = guigetmsg() if $msg <> 0 Then switch $msg case $gui_event_close case Else EndSwitch endif FWP_Events() if $last_fwpsrv_sockets_count <> $fwpsrv_sockets_count then FWP_UpdateSocketsListView($sockets_listview) $last_fwpsrv_sockets_count = $fwpsrv_sockets_count endif WEnd EndFunc Main()oÝ÷ Ø)bz{Z»v®¶sb6æ6ÇVFRfÇC¶wVÆ7GfWræS2fwC° ¦b6ö×ÆVBÒFVâ ÷BgV÷CµG&ÖVçTÖöFRgV÷C²Ã¦VæF` £¶ÖVçRFV×0¥G&6WEFööÅFgV÷C´eu6ÆVçBfW'6öâ"gV÷C² £·F77GV`¥D55F'GW ¤6öç7Bb33c¶gw7'e÷÷'BÒC¤6öç7Bb33c¶gw7'e÷6W'fW"ÒgV÷C´eu5%bgV÷C°¤vÆö&Âb33c¶gw÷6ö6¶WBÒÓ¤vÆö&Âb33c¶gw÷6W'fW%÷FÖW"ÒÓ¤vÆö&Âb33c¶ÖW76vU÷FÖW"ÒÓ ¢b33c·W6W%öBÒgV÷CµvFWfW"÷RvçBBFò&RgV÷C° ¤gVæ2euô6V6µ6ö6¶WB bb33c¶gw÷6ö6¶WBÒÓFVâ b33c¶gw÷6ö6¶WBÒF76öææV7BD5æÖUFôb33c¶gw7'e÷6W'fW"Âb33c¶gw7'e÷÷'B bb33c¶gw÷6ö6¶WBÒÓFVâ G&6WD6öâgV÷C·6VÆÃ3"æFÆÂgV÷C²ÂÓ# b33c¶gw÷6W'fU%÷FÖW"ÒÓ VÇ6P b33c·FV×ÒD56VæBb33c¶gw÷6ö6¶WBÂgV÷C´eu¢gV÷C²fײb33c·W6W%öB b33c¶ÖW76vU÷FÖW"ÒÓ b33c¶gw÷6W'fU%÷FÖW"ÒFÖW&æB G&6WD6öâgV÷C·6VÆÃ3"æFÆÂgV÷C²ÂÓ VæF` VæF`¦VæFgVæ0¤gVæ2euõ6VæEær bb33c¶gw÷6ö6¶WBfÇC²fwC²ÓæBb33c¶ÖW76vU÷FÖW"ÒÓ÷"FÖW&Ffbb33c¶ÖW76vU÷FÖW"ófwC²FVà b33c·FV×ÒD56VæBb33c¶gw÷6ö6¶WBÂgV÷CµærgV÷C² bW'&÷"fÇC²fwC²FVâ b33c¶gw÷6ö6¶WBÒÓ VæF` b33c¶ÖW76vU÷FÖW"ÒFÖW&æB VæF`¦VæFgVæ0¤gVæ2euô6V6´ÖW76vW2 bb33c¶gw÷6ö6¶WBfÇC²fwC²ÓFVâ b33c¶ÖW76vRÒD5&V7bb33c¶gw÷6ö6¶WBÂ#SR bW'&÷"fÇC²fwC²FVâ b33c¶gw÷6ö6¶WBÒÓ &WGW&à VæD` bb33c¶ÖW76vRÒgV÷CµöærgV÷C²FVâ G&6WD6öâgV÷C·6VÆÃ3"æFÆÂgV÷C²ÂÓ b33c¶gw÷6W'fU%÷FÖW"ÒFÖW&æB VÇ6Vb7G&ævÆVgBb33c¶ÖW76vRÂBÒgV÷C´eu¢gV÷C²FVâ ¶vWB6öæf&ÖFöâg&öÒ6W'fW"FBBv÷BFR&vB@ b33c·&VE÷W6W%öBÒ7G&æw&WÆ6Rb33c¶ÖW76vRÂgV÷C´eu¢gV÷C²ÂgV÷C²gV÷C² bb33c·&VE÷W6W%öBfÇC²fwC²b33c·W6W%öBFVà D56Æ÷6U6ö6¶WBb33c¶gw÷6ö6¶WB b33c¶gw÷6ö6¶WBÒÓ VæF` VæF` VæF`¦VæFgVæ0¤gVæ2euô6V6µ6W'fW%7FGW2 bb33c¶gw÷6W'fU%÷FÖW"fÇC²fwC²ÓFVà b33c·FÖUöVÆ6VBÒFÖW&Ffbb33c¶gw÷6W'fU%÷FÖW"ó bb33c·FÖUöVÆ6VBfwC²3FVà G&6WD6öâgV÷C·6VÆÃ3"æFÆÂgV÷C²ÂÓ# G&FgV÷Cµv&æærb333²gV÷C²ÂgV÷C´eu6W'fW"2æ÷B&W7öæFærâ&W7F'B6W'fW"âgV÷C²Â#SR VæD` VæF`¦VæFgVæ0 ¤gVæ2Öâ ¶WfVçG0 vÆRÓ ·F7æBÖW76vRæFÆæp euô6V6µ6ö6¶WB euõ6VæEær euô6V6´ÖW76vW2 euô6V6µ6W'fW%7FGW2 vVæ@¤VæDgVæ0 ¤Öâ I had my server checking to see if there were any notifications to give to the user when they pinged it and had the client doing a little pop-up in the corner if there were. I stripped out all of that so that you can just have it show you who is connected. You'll just need a method of assigning a user name to each client which it will communicate upon connection. You could use the computer's name if nothing else.Server_Client.zip Link to comment Share on other sites More sharing options...
JohnBailey Posted August 8, 2007 Author Share Posted August 8, 2007 so many ideas in there are so cool! I can't seem to get the client to connect to the server. I'm using it on the same machine - just to test it. The client shows the off icon. A decision is a powerful thing Link to comment Share on other sites More sharing options...
JohnBailey Posted August 8, 2007 Author Share Posted August 8, 2007 so many ideas in there are so cool!I can't seem to get the client to connect to the server. I'm using it on the same machine - just to test it. The client shows the off icon.got them talking. Const $fwpsrv_server = '138.219.23.102';"FWPSRV" A decision is a powerful thing Link to comment Share on other sites More sharing options...
JohnBailey Posted August 8, 2007 Author Share Posted August 8, 2007 btw, this should work on all windows NT based systems correct? A decision is a powerful thing Link to comment Share on other sites More sharing options...
JohnBailey Posted August 8, 2007 Author Share Posted August 8, 2007 What am I doing wrong? Server Script (only the major points) expandcollapse popupFunc MainLoop() $text = "Communication Server " & $version $gui = GUICreate($text, 10, 10, -1, -1,BitOr($GUI_SS_DEFAULT_GUI, $ws_sizebox, $ws_maximize)) ;~ GUISetBkColor($wm_guibgcolor) WinSetState($gui, "", @sw_maximize) $temp = WinGetPos($gui) Opt("WinTitleMatchMode", 4) $temp2 = WinGetPos("classname=Shell_TrayWnd") if @error = 1 Then else ;~ winmove($gui, "", $temp[0], $temp[1], $temp[2], $temp[3]-$temp2[3]) EndIf Opt("WinTitleMatchMode", 1) $gui_width = $temp[2] $gui_height = $temp[3]-$temp2[3]-35 $gui_status_listview = guictrlcreatelistview("Date|Time|Description", 20, 20, $gui_width-40, $gui_height-250) $top = $gui_height - 230 $sockets_listview = guictrlcreatelistview("Socket|Idle Time|User ID|User", 20, $top, $gui_width - 40, 200) $last_fwpsrv_sockets_count = 0 while 1=1 ;check gui $msg = guigetmsg() if $msg <> 0 Then switch $msg case $gui_event_close case Else EndSwitch endif FWP_Events() if $last_fwpsrv_sockets_count <> $fwpsrv_sockets_count then FWP_UpdateSocketsListView($sockets_listview) $last_fwpsrv_sockets_count = $fwpsrv_sockets_count endif $fwpsrv_sockets.MoveFirst while not $fwpsrv_sockets.EOF Local $CuN = $fwpsrv_sockets.fields("User Name").value $fwpsrv_sockets.MoveNext Local $recved_message = TCPRecv($fwpsrv_sockets.fields("Socket").value, $MaxLength) FWP_MessageAll($CuN&': '&$recved_message) wend WEnd EndFunc Func FWP_MessageAll($message) FWP_Log("Global message: " & $message) if $fwpsrv_sockets_count > 0 then $fwpsrv_sockets.MoveFirst while not $fwpsrv_sockets.EOF ;check for waiting data TCPSend($fwpsrv_sockets.fields("Socket").value, "Messages" & @CRLF & $message) FWP_Log($fwpsrv_sockets.fields("Socket").value & ": (message sent)") $fwpsrv_sockets.MoveNext WEnd endif endfunc A decision is a powerful thing Link to comment Share on other sites More sharing options...
Hostage Posted August 8, 2007 Share Posted August 8, 2007 In the client, unless you modified the check messages function, it will already have received the contents in the TCP buffer. Therefore, when you do your own TCPRecv in your function here, there's nothing there. Link to comment Share on other sites More sharing options...
JohnBailey Posted August 8, 2007 Author Share Posted August 8, 2007 that makes complete sense! Thank you! Why then does ;check existing connections if $fwpsrv_sockets_count > 0 then $fwpsrv_sockets.MoveFirst while not $fwpsrv_sockets.EOF ;check for waiting data $temp = TCPRecv($fwpsrv_sockets.fields("Socket").value, 255) Local $recved_message = $temp if $temp <> "" Then $user = $fwpsrv_sockets.fields("User Name").value if $temp = "Ping" then TCPSend($fwpsrv_sockets.fields("Socket").value, "Pong") Else FWP_MessageAll($user & ": "&$recved_message) FWP_log($user & ": Sent following:" & $temp) endif $fwpsrv_sockets.fieldS("Timer") = timerinit() endif allow me to send two messages and then drop the user? A decision is a powerful thing Link to comment Share on other sites More sharing options...
JohnBailey Posted August 8, 2007 Author Share Posted August 8, 2007 I understand that when FWP_MessageAll() is called inside of the while not $fwpsrv_sockets.EOF it changes the MoveFirst and MoveNext. How do I send a message. I can't seem to figure it out. I want to use this method, but the best I can do is have the user see that they got a message. A decision is a powerful thing Link to comment Share on other sites More sharing options...
JohnBailey Posted August 9, 2007 Author Share Posted August 9, 2007 This is what I'm trying now: If the received message is not Ping then it will store the Msg and exit the $fwpsrv_sockets.EOF loop and envoke FWP_MessageAll() However, it doesn't work ;check existing connections if $fwpsrv_sockets_count > 0 then $fwpsrv_sockets.MoveFirst while not $fwpsrv_sockets.EOF ;check for waiting data $temp = TCPRecv($fwpsrv_sockets.fields("Socket").value, 255) if $temp <> "" Then $user = $fwpsrv_sockets.fields("User Name").value if $temp = "Ping" then TCPSend($fwpsrv_sockets.fields("Socket").value, "Pong") Else $storedMsg = $temp ;TCPSend($fwpsrv_sockets.fields("Socket").value, $user & ": "&$recved_message) FWP_log($user & ": Sent following:" & $temp) ExitLoop endif $fwpsrv_sockets.fieldS("Timer") = timerinit() endif ;check for time-out and delete $time = timerdiff($fwpsrv_sockets.fields("Timer").value)/1000 if $time > 30 Then ;delete FWP_Log("Connection dropped from " & $fwpsrv_sockets.fields("User Name").value & " on socket " & $fwpsrv_sockets.fields("Socket").value) $fwpsrv_sockets.Delete $fwpsrv_sockets_count -= 1 endif $fwpsrv_sockets.MoveNext WEnd If $storedMsg <> '' then FWP_MessageAll($storedMsg) EndIf A decision is a powerful thing Link to comment Share on other sites More sharing options...
JohnBailey Posted August 9, 2007 Author Share Posted August 9, 2007 Is there a way for it know if there is a connection without sending "Ping" (or other string) A decision is a powerful thing Link to comment Share on other sites More sharing options...
Hostage Posted August 9, 2007 Share Posted August 9, 2007 Is there a way for it know if there is a connection without sending "Ping" (or other string) Yeah, as long as the socket is still open (which it checks for) the connection is still valid- I had the ping event in there in case the server itself froze up but didn't crash (mine has a lot of different things in it). One thing I'd do, is in the MessageAll loops just have it store the ID of where it is at the moment, then return to that at the end. Func MessageAll(...) if not $fwpsrv_sockets.EOF then $start_id = $fwpsrv_sockets.fieldS("ID").value else $start_id = -1 endif ... all the other stuff in here if $start_id <> -1 then $fwpsrv_sockets.MoveFirst $fwpsrv_sockets.Find("[ID]=" & $start_id) endif EndFunc That way you can always be sure you put it back on the record it was on when you got it. Link to comment Share on other sites More sharing options...
JohnBailey Posted August 9, 2007 Author Share Posted August 9, 2007 that works much better than what i was doing!!! Now I just have to figure out how to pull the userlist into each user's listviewgui A decision is a powerful thing 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