summaryrefslogtreecommitdiffstats
path: root/module/remote/ClientSocket.py
diff options
context:
space:
mode:
authorGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2009-05-31 21:06:18 +0200
committerGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2009-05-31 21:06:18 +0200
commit3755da2af7e3f79171d505dd81e0c0b63b4adb9f (patch)
treeb2267b76fe897c3c27ce6ed2a019de08c1394647 /module/remote/ClientSocket.py
parentxupi.in works again (diff)
downloadpyload-3755da2af7e3f79171d505dd81e0c0b63b4adb9f.tar.xz
gui socket finally works
Diffstat (limited to 'module/remote/ClientSocket.py')
-rw-r--r--module/remote/ClientSocket.py36
1 files changed, 23 insertions, 13 deletions
diff --git a/module/remote/ClientSocket.py b/module/remote/ClientSocket.py
index 30eaf20e0..9c52681c7 100644
--- a/module/remote/ClientSocket.py
+++ b/module/remote/ClientSocket.py
@@ -8,31 +8,41 @@ socket for connecting to the core's server
"""
import asynchat
import socket
+import asyncore
+import threading
+import time
from ClientHandler import ClientHandler
+class SocketThread(threading.Thread):
+ def __init__(self, adress, port, pw, client):
+ threading.Thread.__init__(self)
+ sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+ sock.connect((adress, port))
+ self.socket = ClientSocket(sock, pw, client)
+ self.start()
+ def run(self):
+ asyncore.loop()
+ print "loop closed"
+
+
class ClientSocket(asynchat.async_chat):
- def __init__(self, client):
- asynchat.async_chat.__init__(self)
- self.client = client
+ def __init__(self, sock, pw, client):
+ asynchat.async_chat.__init__(self, conn=sock)
self.data = ""
- self.handler = ClientHandler(None)
+ self.handler = ClientHandler(client, pw)
self.set_terminator("\n")
- self.create_socket(socket.AF_INET, socket.SOCK_STREAM)
-
- def handle_connect(self):
- print "connected"
+ #self.create_socket(socket.AF_INET, socket.SOCK_STREAM)
def handle_close(self):
print "Disconnected from", self.getpeername()
self.close()
def collect_incoming_data(self, data):
- print "data arrived"
self.data += data
def found_terminator(self):
- obj = self.handler.proceed(data)
- self.push(obj)
- print "pushed"
- data = ""
+ obj = self.handler.proceed(self.data)
+ #self.push(obj+"\n")
+ print "data arrived"
+ self.data = ""