Jump to content

SplashImageOn when receiving a TCP message


Recommended Posts

Hi you guys,

I been trying to work on some small chat script to communicate with someone across the hall way form my desk, I downloaded some samples and I managed to get one just the way I want it but I want to include some sort of visual warning so the guys at the other end gets notify when getting a new message so I want to include SplashImageOn (or SplashTextOn) but I really don't know where to put it.

Can someone share the light please?

 

Bellow is the code I have so far:

#include <date.au3>

TCPStartup()

$serverIP = '127.0.0.1' 
$serverport = 7660

$srvSocket = TCPListen($serverIP,$serverport)

#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Mensajes Pulpito", 625, 160, 700, 200, BitOr($WS_BORDER, $WS_POPUP), BitOR($WS_EX_TOPMOST, $WS_EX_TOOLWINDOW))
$Edit1 = GUICtrlCreateEdit("", 16, 16, 593, 140)

GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $con = TCPAccept($srvSocket)
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
    If $con >=0 Then
        $rev = ''
        $clientIP = SocketToIP($con)
        ConsoleWrite(@LF & $clientIP)
        While True
            $rev &= TCPRecv($con,2048)
            If @error Then ExitLoop
        WEnd

        If StringLeft($rev,8) = 'MSGPORT#' Then
            $sp = StringSplit($rev,'#')

            $cltSocket = TCPConnect($clientIP,$sp[UBound($sp) - 1])
            If $clientIP <> -1 Then
                TCPSend($cltSocket,GUICtrlRead($Edit1))
                TCPCloseSocket($cltSocket)
            EndIf
        ElseIf $rev <> '' Then
            $str = GUICtrlRead($Edit1)
            $str &=_Now() & @TAB & $rev & @CRLF
            GUICtrlSetData($Edit1,$str)
        EndIf
    EndIf
Sleep(50)
WEnd

Func SocketToIP($SHOCKET)
    Local $sockaddr, $aRet

    $sockaddr = DllStructCreate("short;ushort;uint;char[8]")

    $aRet = DllCall("Ws2_32.dll", "int", "getpeername", "int", $SHOCKET, _
            "ptr", DllStructGetPtr($sockaddr), "int*", DllStructGetSize($sockaddr))
    If Not @error And $aRet[0] = 0 Then
        $aRet = DllCall("Ws2_32.dll", "str", "inet_ntoa", "int", DllStructGetData($sockaddr, 3))
        If Not @error Then $aRet = $aRet[0]
    Else
        $aRet = 0
    EndIf

    $sockaddr = 0

    Return $aRet
EndFunc

Thanks in advance for any help.

 

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...