This repository has been archived by the owner on Nov 29, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
92 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
from loqui.client import LoquiClient | ||
|
||
client = LoquiClient(('localhost', 4001)) | ||
print client.send_request('hello world').data | ||
print len(client.send_request('hello world')) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
from loqui.client import LoquiClient | ||
|
||
client = LoquiClient(('localhost', 4001)) | ||
for i in xrange(100): | ||
client.send_push('hello world %i' % i) | ||
|
||
assert client.send_request('oh hi') == 100 | ||
|
||
for i in xrange(100): | ||
client.send_push('hello world %i' % i) | ||
|
||
assert client.send_request('oh hi') == 200 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
from loqui.server import LoquiServer | ||
|
||
sessions = {} | ||
|
||
|
||
class Server(LoquiServer): | ||
def handle_request(self, request, session): | ||
return sessions[session] | ||
|
||
def handle_push(self, push, session): | ||
sessions[session] += 1 | ||
|
||
def handle_new_session(self, session): | ||
sessions[session] = 0 | ||
|
||
def handle_session_gone(self, session): | ||
sessions.pop(session, None) | ||
|
||
|
||
if __name__ == '__main__': | ||
s = Server(('localhost', 4001)) | ||
s.serve_forever() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters