Chat

« Older   Newer »
  Share  
xMasteRx
CAT_IMG Posted on 25/10/2010, 20:03     +1   -1




una chat tramite ftp è estremamente lenta, ho gia provato a fare tempo fa e per un ping aveva una cosa del genere 15sec XDXD
 
Top
3ad_Pr0grammer
CAT_IMG Posted on 25/10/2010, 20:08     +1   -1




E con una reverse? (Come detto prima..)
 
Top
xMasteRx
CAT_IMG Posted on 25/10/2010, 20:09     +1   -1




sempre il problemma delle TCP D:
se mettete a disposizione un server con la porta aperta si può fare, altrimenti le TCP non si toccano u.u XD
allora, qualcuno ci da in prestito un server? XD
 
Top
MHack
CAT_IMG Posted on 25/10/2010, 20:14     +1   -1




Usiamo le TCP, basta fare un reverse connection. Per aprire le porte ci pensa Autoit, basta che metti TCPConnect($ip,$porta) e la apre da solo, per la reverse si usa no-ip.com.
 
Top
FrontBack
CAT_IMG Posted on 25/10/2010, 20:14     +1   -1




allora dobbiamo usare le tcp, in qualche modo :shifty:
provate a scrivere nella console winzozz ipconfig... forse da lì si può trovare l'ip ;)
 
Top
MHack
CAT_IMG Posted on 25/10/2010, 20:17     +1   -1




No, basta usare _GetIP(). Oppure andare in una pagina dove ti dice l'ip e togliere le cose superflue (cioè tutte xD) tranne l'ip e siamo apposto. Comunque con la reverse non serve l'ip, perchè è il client ad aspettare la connessione.
 
Top
xMasteRx
CAT_IMG Posted on 25/10/2010, 20:17     +1   -1




CITAZIONE (MHack @ 25/10/2010, 21:14)
Usiamo le TCP, basta fare un reverse connection. Per aprire le porte ci pensa Autoit, basta che metti TCPConnect($ip,$porta) e la apre da solo, per la reverse si usa no-ip.com.

la porta del pc non è un problema
il problemma è che sui 95% di noi sta dietro un router/firewall che non abbiamo come accedere per aprire le porte

EDIT: basta che abbiamo un unico computer da usare come server che abbi la porta aperta che possiamo fare tramite le tcp
 
Top
MHack
CAT_IMG Posted on 25/10/2010, 20:20     +1   -1




Proviamo con il codice base della chat di MisterX (quella nella guida per intendersi).
 
Top
FrontBack
CAT_IMG Posted on 25/10/2010, 20:21     +1   -1




di solito se il firewall è fatto con la testa ti dice "Vuoi aprire la connessione verso la rete da parte di questo programma?"

se sono fatti con i piedi, ti dice solo (a caratteri CUBITALI, è ovvio xD) "ATTENZIONE ATTENZIONE, utente incapace: ringrazia il cielo che ti ho bloccato la comunicazione a Internet da parte di questo programma, altrimenti a quest'ora avresti già riformattato quella decina di volte, a tal punto da consumare l'Hard Disk!"

xD
 
Top
MHack
CAT_IMG Posted on 25/10/2010, 20:30     +1   -1




Vabbè, è una chat, mica un controllo remoto. Anche con MSN te lo chiede. "Vuoi permettere a questo programma: msnmgr.exe di connettersi alla rete?"
 
Top
FrontBack
CAT_IMG Posted on 25/10/2010, 20:38     +1   -1




che porta usiamo per la chat?
per il database con i dati del tipo nome utente e ip come facciamo?
io pensavo o al sqlite o alla cosa più stupida e semplice del mondo, un file ini :rolleyes:
 
Top
xMasteRx
CAT_IMG Posted on 25/10/2010, 20:43     +1   -1




io credo che col database sarebbe meglio che lo facesse gianlu che se ne intende [credo XD]
un ini è troppo semplice XD
 
Top
3ad_Pr0grammer
CAT_IMG Posted on 25/10/2010, 20:46     +1   -1




Ho provato a sviluppare una piccola chat con la guida di misterx.. E' una bozza veloce, non so neanche se funziona.

Server:
SPOILER (click to view)
CODICE
;Server ChatB
#include <GUIConstantsEx.au3>
#include <GuiEdit.au3>
#Include <Misc.au3>

TCPStartup()

_Log()



Func _Gui($YourUser, $YourIp, $User, $Socket)
Dim $Banned[2]=["000.000.001", "000.000.000"]        
       
GUICreate("Server ChatB", 298, 362, 361, 191, 0x80000000+0x00040000)
$Edit= GUICtrlCreateEdit("", 0, 0, 297, 329)
GUICtrlSetState(-1,$GUI_DISABLE)
GUICtrlSetData(-1, "Benvenuto in ChatB"&@CRLF&$YourUser&" si è connesso"&@CRLF&"Ip: "&$YourIp&@CRLF)
$Input= GUICtrlCreateInput("", 0, 336, 297, 21)
GUISetState(@SW_SHOW)

       If $YourIp=$Banned Then
               TCPSend($Socket,"Banned")
       EndIf        


While 1
If _IsPressed("1B")=1 Then _Exit()
If _IsPressed("0D")=1 Then
_Send(GUICtrlRead($Input))
EndIf

$Comm=TCPRecv($Socket,2048)

If $Comm <> "" Then
_GUICtrlEdit_AppendText($Edit,$YourUser&": "&$Comm&@CRLF)
EndIf

WEnd
EndFunc

Func _Exit()
$Exit=MsgBox(4, "Sicuro?", "Vuoi disconnetterti?")
If $Exit=6 Then
       TCPSend($Socket, "Disconnesso")
       Exit
EndIf
EndFunc

Func _Send($Send)
                          If $Send<> "" Then
              TCPSend($Socket,$Send)
              GUICtrlSetData($Input,"")
                          GUICtrlSetData($Edit, GUICtrlRead($Edit)&$User&": "&$Send&@CRLF)
                          EndIf
EndFunc          
                 
Func _Log()
$User=InputBox("Attenzione","Inserisci l' username da usare", "Server")
$Login=MsgBox(4, "Login", "Vuoi connetterti?")
If $Login=6 And $User<> "" Then
       
$Listen=TCPListen(@IPAddress1,768)

While 1
      $Socket=TCPAccept($Listen)
      If $Socket <> -1 Then ExitLoop
WEnd
         
Else        
      Exit
EndIf
       
While 1
       $Recv=TCPRecv($Socket,2048)
       If $Recv <> "" Then
               $Sp=StringSplit($Recv, "/\/")
               ExitLoop
       EndIf
WEnd
TCPSend($Socket, $User)
_Gui($Sp[1], $Sp[2], $User, $Socket)
EndFunc


Client:
SPOILER (click to view)
CODICE
;Client ChatB
#include <GUIConstantsEx.au3>
#include <GuiEdit.au3>
#Include <Misc.au3>
Global $Loop=0
TCPStartup()

_Log()

Func _Gui($YourUser, $User, $Socket)
GUICreate("ChatB", 298, 362, 361, 191,0x80000000+0x00040000)
$Edit= GUICtrlCreateEdit("", 0, 0, 297, 329)
GUICtrlSetState(-1,$GUI_DISABLE)
GUICtrlSetData(-1, "Benvenuto in ChatB"&@CRLF&$YourUser&" si è connesso"&@CRLF)
$Input= GUICtrlCreateInput("", 0, 336, 297, 21)
GUISetState(@SW_SHOW)

While 1
If _IsPressed("1B")=1 Then _Exit()
If _IsPressed("0D")=1 Then
_Send(GUICtrlRead($Input))
EndIf

$Comm=TCPRecv($Socket,2048)

If $Comm="Crash" Then
       GUICtrlSetData($Edit, GUICtrlRead($Edit)&"Stai per essere crashato"&@CRLF)
       Sleep(3000)
       Exit
EndIf        

If $Comm="Banned" Then
       TCPSend($Socket, "E' stato bannato")
       GUICtrlSetData($Edit, GUICtrlRead($Edit)&"Sei stato bannato."&@CRLF)
       Sleep(3000)
       Exit
EndIf

If $Comm <> "" Then
_GUICtrlEdit_AppendText($Edit,$YourUser&": "&$Comm&@CRLF)
EndIf

WEnd
EndFunc

Func _Exit()
$Exit=MsgBox(4, "Sicuro?", "Vuoi disconnetterti?")
If $Exit=6 Then
       TCPSend($Socket, "Disconnesso")
       Exit
EndIf
EndFunc

Func _Send($Send)
                  If $Send<> "" Then
              TCPSend($Socket,$Send)
              GUICtrlSetData($Input,"")
                          GUICtrlSetData($Edit, GUICtrlRead($Edit)&$User&": "&$Send&@CRLF)
                          EndIf
EndFunc                

Func _Log()
$User=InputBox("Attenzione","Inserisci l' username da usare")
$Login=MsgBox(4, "Login", "Vuoi connetterti?")
If $Login=6 And $User<> "" Then
$Socket=TCPConnect(@IPAddress1,768)
If $Socket=-1 Then    
      MsgBox(16,"Attenzione","Servizio momentaneamente non disponibile",5)
      Exit
  EndIf
  Else
Exit
EndIf

TCPSend($Socket, $User&"/\/"&@IPAddress1)
While 1
       $YourUser=TCPRecv($Socket,2048)
       If $YourUser<> "" Then
               ExitLoop
       EndIf
       If $Loop>300 Then
   TCPSend($Socket, $User)        
   $Loop=0
   EndIf
               
               $Loop=$Loop+1
       WEnd
_Gui($YourUser, $User, $Socket)
EndFunc


Sicuramente c' è qualche bug..
 
Top
Cale92
CAT_IMG Posted on 25/10/2010, 20:48     +1   -1




bisognerebbe allegare alla chat un modo per sbloccare le porte del router in modo che tutti lo sappiano fare.. comunque direi che il modo migliore è usare una tcp con connessione reverse.. miky1985 aveva fatto un controllo remoto con connessione reverse(non so se funziona) e aveva detto che mi passava il codice ma non si è più fatto sentire..
 
Top
FrontBack
CAT_IMG Posted on 25/10/2010, 20:53     +1   -1




bug nel server, linea 52
riporto testualmente dall'errore:

CITAZIONE
Line 52 (File: "D:\Utenti\****\Documenti\Laboratorio AutoIt v3\ChatB\Server.au3"):

TCPSend($Socket,$Send)
TCPSend(^ ERROR

Error: Variable used without being declared.

Praticamente invii un messaggio dal client e il server fa cilecca :)
 
Top
132 replies since 25/10/2010, 16:00   1153 views
  Share