-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathcmpp_manager.py
More file actions
101 lines (79 loc) · 1.94 KB
/
cmpp_manager.py
File metadata and controls
101 lines (79 loc) · 1.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
from cmpp_handle import *
from cmpp_net import *
class cmppManager(object):
connectedISMG = False
'''
@cmpp需要的配置信息
'''
@staticmethod
def initConfig():
cmppManager.setServerIP("127.0.0.1")
cmppManager.setServerPort(10086)
cmppManager.setSrcID("100861121")
cmppManager.setSPID("417393")
cmppManager.setServiceID("AHB0090102")
cmppManager.setPassword("888888")
'''
@发送短信,也是短信模块的入口函数
'''
@staticmethod
def submitMessage(message, number):
if cmppManager.connectedISMG != True:
cmppManager.initConfig()
ret,sockFd = cmppHandle.connectISMG(cmppManager.IP, cmppManager.PORT)
if ret == 0 and sockFd > 0:
cmppManager.connectedISMG = True
#认证成功后,开启新的现场进行保活处理
cmppHandle.service(sockFd)
else :
print('connected ISMG failed')
cmppManager.connectedISMG = False
return -1
if cmppHandle.sendMessage(sockFd, message, number) == 0 :
print("send message success")
else:
print("send message failed")
#网关IP
@staticmethod
def getServerIP():
return cmppManager.IP
@staticmethod
def setServerIP(ip):
cmppManager.IP = ip
#网关端口
@staticmethod
def getServerPort():
return cmppManager.PORT
@staticmethod
def setServerPort(port):
cmppManager.PORT = port
#服务代码
@staticmethod
def getSrcID():
return cmppManager.SRCID
@staticmethod
def setSrcID(srcid):
cmppManager.SRCID = srcid
#企业代码
@staticmethod
def getSPID():
return cmppManager.SPID
@staticmethod
def setSPID(spid):
cmppManager.SPID = spid
# 业务代码
@staticmethod
def getServiceID():
return cmppManager.SERVICEID
@staticmethod
def setServiceID(serviceid):
cmppManager.SERVICEID = serviceid
#密码
@staticmethod
def getPassword():
return cmppManager.PWD
@staticmethod
def setPassword(pwd):
cmppManager.PWD = pwd
if __name__ == "__main__":
cmppManager.submitMessage("Helloworld", "10086")