Sign in to follow this  
Followers 0
PoopDeck

I must be really tired

14 posts in this topic

#1 ·  Posted (edited)

I'm very confused as to why this is so laggy. I don't even know if it connects. I made the connection part Commented out so it defaults to connecting to yourself.

The connecting to yourself works, I however do not understand why this is so so so so so laggy :/ ...

If some1 could help me out that'd be appreciated. Thx.

#include <GuiConstants.au3>
#include <Date.au3>
#include <File.au3>
#Include <GuiEdit.au3>
$GUI = GuiCreate( "Chat Thing", 500, 500, -1 , -1 , $WS_SIZEBOX+$WS_MINIMIZEBOX+$WS_MAXIMIZEBOX)
$inputline = GUICtrlCreateInput( "", 20, 420, 450, 20, $ES_AUTOHSCROLL)
$editbox = GUICtrlCreateEdit( "", 1, 1, 499, 418, $ES_READONLY + $WS_VSCROLL)
GuiCtrlSetBKColor( $editbox, 0x000000)
GuiCtrlSetBKColor( $inputline, 0x000000)
GuiCtrlSetColor( $editbox, 0xFFFFFF)
GuiCtrlSetColor( $inputline, 0xFFFFFF)
$menu = GUICtrlCreateMenu("Connect" )
$menu2 = GuiCtrlCreateMenuItem("Connect", $menu)

GuiSetState(@SW_SHOW,$gui)



UDPStartUp()
$IP = @IPAddress1
$socket = UDPBind($ip, 3567)
If @error <> 0 Then Exit
$connected = 0
$userip = @IPAddress1   

$user = inputbox("username", "Please choose a user name: ")
$list = 0

while 1
    
    $msg = GUIGetMsg()
    $data = UDPRecv($socket, 50)
    If $msg = $GUI_EVENT_CLOSE then exit
    if $msg = $menu2 then connect()
    if $data <>  "" then Recvmsg()
    If $msg = $inputline Then Sendmsg()

WEnd

Func connect()
    
    $userip = inputbox("Connect", "Ip of user you would like to connect to.")
    
    ;Global $socket2 = UDPOpen( $userip, 3567)
    Global $socket2 = UDPOpen(@ipaddress1, 3567)
    Global $connected = 1
    
    
    
EndFunc 

Func RecvMsg()
    


$string = $data
_GUICtrlEdit_AppendText( $editbox, $string)
_GUICtrlEdit_Scroll( $editbox, $SB_SCROLLCARET)
GUICtrlSetData($inputline, "")

EndFunc


func Sendmsg() 
    

$theinput = GuiCtrlRead($inputline)
$string = ("["&_NowTime(5)&"]"&"<"&$user&">"&$theinput&@CRLF)

    
if $connected = 1 then UDPSend($socket2, $string)   

_GUICtrlEdit_AppendText( $editbox, $string)
_GUICtrlEdit_Scroll( $editbox, $SB_SCROLLCARET)
GUICtrlSetData($inputline, "")

EndFunc 
    
Func OnAutoItExit()
    UDPCloseSocket($socket)
    UDPShutdown()
EndFunc

thx.

Edit. I did find the problem. If All UDP functions are commented out in the while1 and everywhere else, There is no lag or delay with typing or sending data.

Edited by PoopDeck

Share this post


Link to post
Share on other sites



Bump

Share this post


Link to post
Share on other sites

what exactly is laggy?

i tested the code for a sec, but only with me in chat. there wasnt something reaaaly laggy.

btw:

Global $socket2 = UDPOpen(@ipaddress1, 3567)

Global $connected = 1

always at top of the file not in a function

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

PoopDeck -

I don't know how to write the code that tests whether you are connected, but you would do well to have such code.

It is completely my intuition that your machine needs maintenance. When is the last time you used cleanmgr.exe to cleanup the old System Restore points?

Defrag lately? You know there is a paging file defragger available at this post.

You confess you are tired - put down the coffee and lay down.

Edited by Squirrely1

Das Häschen benutzt Radar

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Make it to a .exe file and run it twice- you should be able to write youself.

Why i didn´t test?

I did :) but your code got some errors, i am not able to start the compiled code...

Edited by Kademlia

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

while 1
   
    $msg = GUIGetMsg()
    $data = UDPRecv($socket, 50) ;< HERE IF i comment this out i get no lag
    If $msg = $GUI_EVENT_CLOSE then exit  
    if $msg = $menu2 then connect()
    if $data <>  "" then Recvmsg() ;< If this and the above ^ are both commented out i get no lag
    If $msg = $inputline Then Sendmsg()

WEnd

Also squirrely1 I think you are very right on that. Having 4 partitions 2 systems , Vista and XP and files galore everywhere on 250gb hd is slowing down my machine and i do need to defragment

squirrely1: When is the last time you used cleanmgr.exe to cleanup the old System Restore points?

Never. Ill check that out

i don't think it's a system problem however seeing as every single program i have runs fine and the lag is from $data = UDPRecv($socket, 50)

I am utterly confused :/.

and yes i was on 2 hours of sleep in 48 hours b4 so yea and i did go to sleep after that post. :)

This code i think uses beta so maybe if your not using beta or an outdated beta or possibley i'm using outdated beta kademlia that could be your problem with not being able to start compiled code because i was perfectly able to.

Edit: Also the problem is not with connecting, I haven't even tried to see if i can connect or not. I know for a fact that you can connect to yourself because ive tested it for that. If u look in the code when u click connect it connects to urself anyway w/e u type into the input b/c i disabled that for testing purposes.

So connecting is not the problem. The problem is for example, Im typing here right now and instead of it being instant (near instant) it lags or delays and when i stop typing it continues typing b/c it was delayed.

That is the problem i am having. thx.

Edited by PoopDeck

Share this post


Link to post
Share on other sites

bump

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

As it does not lag for me:

1 .DL latest beta if your havent.

2. Buy a PC with more thant ~1ghz ^^

3. Play with Sleeps and Inset Timers to find what exactly lags for you

Edit: Btw - as i was NOT able to make your script to an exe you should find this problem and fix it. Maybe it fixes your other problems!

Edited by Kademlia

Share this post


Link to post
Share on other sites

kk ill dl newest beta and i have dual core 2.4 :) :/. Thx.

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

I redownloaded beta. Now it doesn't work on beta. It works fine however on nomral (With lag)

$GUI = GuiCreate("Chat Thing", 500, 500, -1, -1, $WS_SIZEBOX+

---------------------------------------------------------------^ERROR

Varriable used without being declared

.....I dont know why this is happening on the beta i just downloaded. Could be b/c it's beta :/

Problem remains. Think of it like this. When you type into an aim window or msn That isn't delayed. Imagine if it was...

Edited by PoopDeck

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

Basically i'm getting lag from having $data = UDPRecv($socket, 50) in a while.

For example:

While 1

$data = udprecv($socket, 50)

if $data <> "" then function()

wend

Edited by PoopDeck

Share this post


Link to post
Share on other sites

bump

Share this post


Link to post
Share on other sites

Dunno why.

Make less cheks to work around

CODE
$begin = TimerInit()

$data = ""

while 1

$msg = GUIGetMsg()

If TimerDiff($begin) > 2000 then

$data = UDPRecv($socket, 500)

$begin = TimerInit()

endif

If $msg = $GUI_EVENT_CLOSE then exit

if $msg = $menu2 then connect()

if $data <> "" then Recvmsg()

If $msg = $inputline Then Sendmsg()

WEnd

search the forum for other chats and check how they worked around

Share this post


Link to post
Share on other sites

This wont work... You have to have another program that opens a server to chat on.. You can't just connect to an IP and expect it to work.

Share this post


Link to post
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
Sign in to follow this  
Followers 0