Permalink
Browse files

deleted: hwjson.ahk

	new file:   hwjsonclient.ahk
	modified:   hwjsonserver.py
	modified:   hwserver.py
	new file:   lib/json.ahk
	new file:   lib/tostring.ahk
	modified:   lib/zmq.ahk
	modified:   libzmq.dll
	new file:   scratch.ahk
  • Loading branch information...
1 parent c1532e3 commit 6ee8f3cc834c2120a9f0cda154fe354374d56e91 @tinku99 committed Apr 18, 2012
Showing with 411 additions and 29 deletions.
  1. +0 −19 hwjson.ahk
  2. +48 −0 hwjsonclient.ahk
  3. +0 −4 hwjsonserver.py
  4. +0 −5 hwserver.py
  5. +328 −0 lib/json.ahk
  6. +30 −0 lib/tostring.ahk
  7. +3 −1 lib/zmq.ahk
  8. BIN libzmq.dll
  9. +2 −0 scratch.ahk
View
@@ -1,19 +0,0 @@
-EnvGet, path, PATH
-EnvSet, PATH, % ";" A_ScriptDir . "\Debug"
-DllCall("LoadLibrary", "str", "ahk.dll")
-context := dllcall("ahk\acontext", "cdecl ptr")
-socket := dllcall("ahk\areqsocket", "ptr", context
-, "astr", "tcp://localhost:5555"
-, "cdecl ptr")
-loop, 5{
-msg := ["hello", A_Index]
-jmsg := json_to(msg)
-hr := dllcall("ahk\asendrecv", "ptr", socket, "astr", jmsg, "uint", strlen(jmsg)
-, "cdecl astr")
-sleep, 500
-tooltip % hr
-}
-return
-
-!r::reload
-!q::exitapp
View
@@ -0,0 +1,48 @@
+z := new zmq()
+context := z.zmq_init(1)
+tooltip, % "Connecting to hello world server…"
+requester := z.zmq_socket(context, z.ZMQ_REQ)
+
+hr := z.zmq_connect(requester, "tcp://localhost:5555")
+assert(hr)
+VarSetCapacity(request, 16, 0)
+omsg := ["hello", "world"]
+msg := json_to(omsg)
+hr := z.zmq_msg_init_size(&request, strlen(msg))
+assert(hr)
+msgp := z.zmq_msg_data(&request)
+strput(msg, msgp, strlen(msg) , "utf-8")
+tooltip % "Sending`n" msg
+hr := z.zmq_send(requester, &request, 0)
+assert(hr)
+hr := z.zmq_msg_close(&request)
+assert(hr)
+VarSetCapacity(reply, 16, 0)
+hr := z.zmq_msg_init(&reply)
+assert(hr)
+hr := z.zmq_recv(requester, &reply, 0)
+assert(hr)
+size := z.zmq_msg_size(&reply)
+msgp := z.zmq_msg_data(&reply)
+msg := StrGet(msgp, size, "utf-8")
+hr := z.zmq_msg_close(&reply)
+hr := z.zmq_close(requester)
+hr := z.zmq_term(context)
+msgbox, % "Received " msg " of size: " size
+jmsg := json_from(msg)
+msgbox % tostring(jmsg)
+return
+!r::reload
+!q::exitapp
+assert(hr){
+if ErrorLevel{
+listlines
+msgbox % ErrorLevel
+}
+if hr
+msgbox % "error: " hr
+}
+return
+
+#include lib\zmq.ahk
+#include lib\json.ahk
View
@@ -10,10 +10,6 @@
message = socket.recv_json()
print "Received request: ", message
- # Do some 'work'
-# time.sleep (1) # Do some 'work'
-
- # Send reply back to client
socket.send_json(["World", message])
View
@@ -9,11 +9,6 @@
# Wait for next request from client
message = socket.recv()
print "Received request: ", message
-
- # Do some 'work'
-# time.sleep (1) # Do some 'work'
-
- # Send reply back to client
socket.send("World")
Oops, something went wrong.

0 comments on commit 6ee8f3c

Please sign in to comment.