MCPcopy Create free account
hub / github.com/EasyIME/PIME / Client

Class Client

python/server.py:28–58  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

26
27
28class Client(object):
29 def __init__(self, server):
30 self.server = server
31 self.service = None
32
33 def init(self, msg):
34 self.guid = msg["id"]
35 self.isWindows8Above = msg["isWindows8Above"]
36 self.isMetroApp = msg["isMetroApp"]
37 self.isUiLess = msg["isUiLess"]
38 self.isUiLess = msg["isConsole"]
39 # create the text service
40 self.service = textServiceMgr.createService(self, self.guid)
41 return (self.service is not None)
42
43 def handleRequest(self, msg): # msg is a json object
44 method = msg.get("method")
45 seqNum = msg.get("seqNum", 0)
46 # print("handle message: ", str(id(self)), method, seqNum)
47 service = self.service
48 if service:
49 # let the text service handle the message
50 reply = service.handleRequest(msg)
51 else: # the text service is not yet initialized
52 reply = {"seqNum": seqNum}
53 success = False
54 if method == "init": # initialize the text service
55 success = self.init(msg)
56 reply["success"] = success
57 # print(reply)
58 return reply
59
60
61class Server(object):

Callers 1

runMethod · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected