How to use msg method in green

Best Python code snippet using green

string.js

Source:string.js Github

copy

Full Screen

1<script>2var TAB_CODE=93var DEL_CODE=46 4var BS_CODE=85var SP_CODE=326var DOT_CODE=1907var DOT2_CODE=1108var IDX_ON=09var IDX_OFF=110var IDX_AP_MODE=011var IDX_CBRIDGE_MODE=112var IDX_WWAN_MODE=213var IDX_KAI_MODE=314var IDX_MBRIDGE_MODE=415var WIRELESS_AP_MODE=0;16var WIRELESS_CBRIDGE_MODE=1;17var WIRELESS_CWAN_MODE=2;18var WIRELESS_KAI_MODE=3;19var WIRELESS_MBRIDGE_MODE=4;20var KAID_MODE_INIT=0 // ap mode21var KAID_MODE_PSP=0 // psp kai22var KAID_MODE_NORMAL=0 // xbox kai23var AUTH_OPEN=124var AUTH_KEY=225var AUTH_AUTO=326var AUTH_WPA=427var AUTH_WPAPSK=528var AUTH_OPEN8021X=629var AUTH_WPANONE=730var AUTH_WPA2=831var AUTH_WPA2PSK=932var AUTH_WPAPSKWPA2PSK=1033var AUTH_NOCHANGE=10034var IDX_NOENC=035var IDX_WEP64=136var IDX_WEP128=237var IDX_TKIP=338var IDX_AES=439var IDX_TKIPAES=540var ENCRYPT_OFF=041var ENCRYPT_64=142var ENCRYPT_128=243var ENCRYPT_TKIP=344var ENCRYPT_AES=445var ENCRYPT_TKIPAES=546var KEY_STRING=0;47var KEY_HEX=1;48var IDX_KEY_STRING=0;49var IDX_KEY_HEX=1;50var REGION_USA=1;51var REGION_JAPAN=2;52var DMZTWINIP_MODE_DMZ=1;53var DMZTWINIP_MODE_TWINIP=2;54var QOS_SHARING_BOUNDED=2;55var QOS_SHARING_BORROW=3;56var MSG_RESTART_CONFIRM_UPNP='改变UPNP配置后系统将重新启动.\n您是否确定更改 ? ';57var MSG_RESTART_CONFIRM_REBOOT='系统即将重启.\n您是否确定更改?';58var MSG_RESTART_CONFIRM_CHANGE_LANIP='更改局域网IP地址后系统将重启.\n您是否确定更改 ?';59var MSG_RESTART_CONFIRM_CHANGE_LANIP_FAKE_TWINIP='更改局域网IP地址后系统将重启.\n您是否确定更改 ?';60var MSG_RESTART_CONFIRM_WIRELESS='更改无线模式后系统将重启.\n您是否确定更改 ?';61var MSG_KAID_MODE_CHANGE_WARNING='修改KAI模式后系统将重启.\n您是否确定更改 ?';62var MSG_RESTART_CONFIRM_WIRELESS_CBRIDGE='更改无线模式后系统将重启.\n您是否确定更改?';63var MSG_RESTART_CONFIRM_WIRELESS_WWAN='更改无线模式后系统将重启.\n您是否确定更改?';64var MSG_TWINIP_CONFIRM_WARNING='应用Twin IP后系统将重启.\n您是否确定更改 ? ';65var MSG_WAN_FOR_LAN_WARNING='更改广域网配置后系统将重启\n确定?';66// common67var MODIFY_OP='Modify'68var MSG_INVALID_HWADDR="无效的MAC地址." 69var MSG_DELETE_RULE_CONFIRM="规则将被删除.\n您是否确定更改?" 70var MSG_SELECT_RULE_TO_DEL="选择要删除的规则."71var MSG_ALL_STOP_RULE="您想清除所有规则吗?"72var MSG_OPENER_PAGE_MOVED="页面变更."73var MSG_INVALID_VALUE="无效值."74// wireless_config_wizard75var MSG_INVALID_WEP_KEY_HEXVALUE2="网络密钥应该是十六进制的字符串."76var MSG_INVALID_WPAPSK_KEY_MISMATCH="不同的网络密钥.\n填写相同的密钥."77//NAT路由 MSG_RULE_NAME_IS_BLANK="规则名称是空白的."78// wirelessconf_wdssetup79var MSG_WDS_DEL_WARNING="您确定要删除WDS吗?" 80var MSG_APADD_REQUEST_APPLY="如果按 '增加' 按钮, WDS配置将完成."81var MSG_NO_DEL_WDS="选择要删除的WDS!"82// wirelessconf_basicsetup83var MSG_BLANK_SSID="输入SSID."84var MSG_INVALID_WEP_KEY_LENGTH="无效的网络密钥长度."85var MSG_INVALID_WEP_KEY_HEXVALUE="网络密钥应为十六进制."86var MSG_INVALID_WPAPSK_KEY_LENGTH="网络密钥应超过8个字符."87var MSG_INVALID_5_KEY_LENGTH="网络密钥应为5个字符."88var MSG_INVALID_13_KEY_LENGTH="网络密钥应为13个字符."89var SAVE_CONFIGURATION_STRING="保存所有配置?"90var MSG_BLANK_REQUEST_SSID="输入SSID,并按“应用”按钮."91var MSG_INVALID_REQUEST_KEY="输入网络密钥并按“应用”按钮."92var MSG_INVALID_REQUEST_APPLY="按“应用”按钮连接指定的AP."93var MSG_APPLY_REQUEST_KEY="按“应用”按钮应用1信道"94var MSG_BEST_CHANNEL_PRE="最好的信道是 " 95var MSG_BEST_CHANNEL_POST="1信道"96var MSG_KEY_LENGTH_DESC="密钥长度 = "97// 配置向导 MSG_BLANK_ACCOUNT="输入用户名."98var MSG_BLANK_PASSWORD="输入密码."99var MSG_INVALID_IP="无效的IP地址."100var MSG_INVALID_NETMASK="无效的子网掩码."101var MSG_INVALID_GATEWAY="无效的网关地址."102var MSG_INVALID_FDNS="无效的首选DNS"103var MSG_INVALID_SDNS="无效的次级DNS"104//netconf_lansetup105var NETCONF_INTERNAL_INVALID_NETWORK="局域网IP地址和广域网IP地址相同."106var STATIC_LEASE_ALREADY_EXIST_IPADDRESS="此IP地址已被添加."107var STATIC_LEASE_ALREADY_EXIST_HWADDRESS="此MAC地址已被添加."108var MSG_ERROR_NETWORK_LANIP="局域网IP地址不能和广域网IP地址相同"109var MSG_ERROR_BROAD_LANIP="局域网IP地址不能和本地广播地址相同"110//netconf_wansetup111//netconf_lansetup112var NETCONF_INTERNAL_INVALID_DHCP_S_ADDR="无效的DHCP地址池开始"113var NETCONF_INTERNAL_INVALID_DHCP_E_ADDR="无效的DHCP地址池结束"114var NETCONF_INTERNAL_INVALID_DHCP_ADDR="无效的DHCP池范围"115var NETCONF_INTERNAL_DELETE_IP="是否要删除此保留的IP地址?"116// wirelessconf_advanced117var DESC_INVALID_TX_POWER="TX功率应该是从1到100.";118var DESC_INVALID_RTS_THRESHOLD="RTS门限应该从1到2347.";119var DESC_INVALID_FRAG_THRESHOLD="碎片化门槛应从256到2346.";120var DESC_INVALID_BEACON_INTERVAL="Beacon 周期应为50至1024.";121// expertconf_kai122var KAID_MODE_CHANGE_WARNING="重新启动系统。你确定要继续吗 ?"123var KAID_MUST_SELECT_OBT_SERVER="至少,一个服务器应该被选择."124var KAID_RESTART_KAI_UI="请重新启动用户界面."125//natrouterconf_portforward126var MAX_PORT_FORWARD=60127var NATCONF_PORTFORWARD_NO_MORE_RULE="不能再添加更多的端口."128var NATCONF_PORTFORWARD_INVALID_INT_IP_ADDRESS="无效的内部IP地址."129var NATCONF_PORTFORWARD_EXT_PORT_IS_BLANK="外部端口是空白的"130var NATCONF_PORTFORWARD_INVALID_EXT_PORT="无效的外部端口."131var NATCONF_PORTFORWARD_INVALID_EXT_PORT_RANGE="无效的外部端口范围."132var NATCONF_PORTFORWARD_INVALID_INT_PORT="无效的内部端口."133var NATCONF_PORTFORWARD_INVALID_INT_PORT_RANGE="无效的内部端口范围"134var NATCONF_PORTFORWARD_RUN_RULE="你想应用规则吗?"135//firewallconf_firewall136var USER_FWSCHED_TYPE=1137var APP_FWSCHED_TYPE=2138var URL_FWSCHED_TYPE=4139var MAX_FWSCHED_COUNT=200 140var FIREWALLCONF_FIREWALL_INVALID_TIME_TO_BLOCK="无效的时间范围."141var FIREWALLCONF_FIREWALL_DATE_WARNING="选择时间范围."142var FIREWALLCONF_FIREWALL_INVALID_SOURCE_IP="无效的源IP地址."143var FIREWALLCONF_FIREWALL_INVALID_SOURCE_HW="无效的源IP地址."144var FIREWALLCONF_FIREWALL_INVALID_DEST_IP="无效目的地址."145var FIREWALLCONF_FIREWALL_INVALID_DEST_PORT="无效的目的端口."146var FIREWALLCONF_FIREWALL_RUN_RULE="您想应用规则吗?"147var FIREWALLCONF_FIREWALL_NO_MORE_RULE="没有更多的帐户."148var FIREWALLCONF_FIREWALL_INVALID_PRIORITY="无效的优先."149//firewallconf_netdetect150var NETCONF_NETDETECT_WARNING1="最小连接值为10."151var NETCONF_NETDETECT_WARNING2="0 ~ 23 范围值"152//firewallconf_internet153var FIREWALLCONF_INTERNET_RESTRICTIVE_WARNING="PC的数量应从1~253."154var FIREWALLCONF_INTERNET_RESTRICTIVE_CLEARANCE="您想清除所有的PC配置信息?"155//trafficconf_switch156var SELECT_VLAN_PORT_WARNING ="选择端口."157var SELECT_VLAN_PORT_TRUNK_WARNING ="所有的端口(%s) 必须在VLAN内."158var SELECT_TRUNK_PORT_WARNING ="选择中继端口."159var SELECT_TRUNK_PORT_VLAN_WARNING ="所有端口必须在VLAN(%s) 或者其他的VLAN."160var MAX_MEMBER_TRUNK_WARNING="最大端口数 %d."161var ALREADY_OTHER_GROUP_MEMBER="端口不能包含在多个组中."162//trafficconf_loadshare163var NATCONF_PORTFORWARD_NO_MORE_RULE="没有更多的添加端口."164var NATCONF_PORTFORWARD_RULE_NAME_IS_BLANK="规则名称空白."165var NATCONF_INTSERVER_INVALID_EXT_PORT="无效的端口."166var NATCONF_LOADSHARE_KEEP_WRR="当WRR LS激活您可以关闭自动备份功能." 167var NATCONF_LOADSHARE_ON_LINE_BACKUP="自动备份也将被激活。您想继续吗?"168var NATCONF_LOADSHARE_DELETE_RULE="是否要删除规则?"169var NATCONF_PORTFORWARD_SELECT_RULE_TO_DEL="选择要检测的规则."170//sysconf_login171//reboot172var REBOOT_CHANGEIP_RETRY_LOGIN="由于本地IP地址的更改,请重新连接."173var REBOOT_CHANGEIP_RETRY_NOLOGIN_WINDOWS="重新连接到配置页."174// wirelessconf_multibssid175var MSG_DEL_MBSSID_WARNING="无线网络将被删除。你确定要继续吗 ?"176var MSG_MBSSID_QOS_WARNING="最小值为 100 Kbps."177//sysconf_misc178var MSG_WBM_POPUP="重新连接."179// trafficconf_switch180var MSG_SAME_PORT_MIRROR="同样的端口不能被镜像."181var MSG_HUBMODE_WARNING="!!! 警告 !!\nHUB模式,NAT路由功能将停止并设置无法连接配置页面。\n \n\n继续? "182var MSG_HUBMODE_CONFIRM="按“确定”按钮继续."183// trafficconf_portqos184var MSG_PORTQOS_BOTH_ZERO=": 0 Mbps 不能被配置."185var MSG_PORTQOS_MAX_ERROR=": 大于100 Mbps 不能被配置."186var MSG_PORTQOS_INVALID_VALUE=": 无效(应该为 "187// wirelessconf_multibridge188var MSG_DEL_WWAN_WANRING="有线广域网端口(广域网端口) 将被关闭. 您是否想继续?"189// iframe_pppoe_sched190var MSG_INVALID_HOUR_VALUE="小时范围为 0 ~ 23."191var MSG_INVALID_MIN_VALUE="分钟范围为0 ~ 59."192var MSG_PPPOE_SCHEDULE_SAME_RULE="相同的时间表已经存在."193// trafficconf_lspolicy194var MSG_BACKUP_METHOD_AT_LEAST_ONE="至少选择一个程序"195var MSG_BACKUP_METHOD_DOMAIN="应指定域名"196var MSG_INVALID_PROTONUM="Invalid Proto Num"197var MSG_MBRIDGE_AUTO_CHANNEL_STRING="[自动搜索信道] 此功能在搜索其他的AP源信号的信道.\n\当网桥功能丢失那么这个AP将保持连接上级AP,这个功能可以保持AP功能有效.\n\所以,我们不建议使用网桥功能和AP功能,只有当 [自动搜索信道] 未开启.\n\继续?";198var TRAFFICCONF_ALL_OPTIONS_CLEAR = "所有的选项将清除.\n继续?"199var MSG_SELECT_DEL_MBSS = "选择要删除的无线网络."200var AUTO_STRING = "自动"201var MBRIDGE_AUTO_CHANNEL_SEARCH = "自动搜索信道"202var UPPER_CHANNEL_TXT = "低级的"203var LOWER_CHANNEL_TXT = "高级的"204var LAN_GATEWAY_WARNING_MSG = "当没有广域网连接时,此选项对路由器本身连接互联网是有效的.\nContinue?";205var MSG_IPPOOL_MAX_WARNING = "没有使用IP地址的范围."206var MSG_DFS_WARNING="这个频道是DFS信道.\n只有在雷达信号被发现时才被激活 1 ~ 10 minutes."207var SYSCONF_LOGIN_BLANK_ID = "账户是空的."208var SYSCONF_LOGIN_BLANK_PASS = "密码是空的."209var SYSCONF_LOGIN_REMOVE_WARNING = "删除帐户/密码。继续?"210var MSG_PPTPVPN_REBOOT = "改变PPTP VPN后重新启动服务器?"211var MSG_QOS_REBOOT="改变QoS配置后重新启动."212var DESC_INVALID_DCS_PERIOD="范围应 1 ~ 100."213var INVALID_HOUR_TEXT="范围应 0 ~ 23."214var INVALID_MIN_TEXT="范围应 0 ~ 59."215var SELECT_DAY_DESC="最少一天检查一次."216var SNMP_INVALID_PORT= "端口范围 1 - 65535."217var SNMP_COMMUNITY_ALERT= "域为强制性."218var MSG_INVALID_RADIUS_SERVER="无效的RADIUS服务器地址"219var MSG_INVALID_RADIUS_SECRET="无效的RADIUS服务器密码"220var MSG_INVALID_RADIUS_PORT="无效的RADIUS服务器端口"221var MSG_WEP_WARNING="最大连接数率 54Mbps(11g) 当选择WEP或者TKIP.\n继续?"222var MSG_WEP_SEC_WARNING="WEP是很弱的加密设置.我们不推荐使用WEP.\n使用WEP或者不使用?"223var MSG_WIRELESS_WAN_WARNING="无线广域网功能已经被另一个无线接口使用了。关闭其他无线接口中的无线广域网功能."224var MSG_WDS_CHANNEL_WARNING="信道匹配不对.\n更改信道后应用.\n继续?"225var MSG_NEW_BSS="新的无线网络"226var MSG_ADD_MAC_WARNING="没有检查添加的地址."227var MSG_REMOVE_MAC_WARNING="没有检查删除的地址."228var MSG_NEED_REBOOT_FOR_WWAN="系统将被重新启动。继续?"229var PASSWORD_NEEDED_TO_SET_THIS="应更改帐户和密码,以启用此功能.\n设置帐户和密码 [系统]->[账号配置]页面."230var SYSCONF_LOGIN_NEED_CAPTCHA_CODE="填写安全码"231var MSG_SELECT_ITUNES_FOLDER_ERR="选择iTunes文件夹."232var MSG_USB_MODE_WARNING="改变USB模式,应该重新启动系统.\n继续?"233var MSG_HWADDR_NO_INPUT=MSG_INVALID_HWADDR234var MSG_SELECT_MAC_REMOVED=NATCONF_PORTFORWARD_SELECT_RULE_TO_DEL235// NASCONF236var MSG_NASCONF_SAME_AS_MGMT_PORT="路由器管理端口使用的同一个端口.\n首先,更改路由器管理端口和使用此端口."237// WIRELESSCONF238var MSG_5G_LOW_CHANNEL_WARNING="低功率信道选择。推荐使用 [149-161] 长覆盖信道."239var MSG_5G_USA_CHANNEL="[美国,加拿大] 区域支持高功率。在其他国家使用可以禁止国家规定."240var MSG_DYNAMIC_CHANNEL_WARNING="如果信道被使用, [动态信道搜索] 功能将被禁用\n继续?"241var PLUGIN_INSTALL_BT_TXT="安装"242var PLUGIN_UPDATE_BT_TXT="升级"243var PLUGIN_CANCEL_BT_TXT="清除"244var PLUGIN_REMOVE_BT_TXT="移动"245var MSG_TOO_LONG_SSID="SSID长度太长.\n非ASCII字符有3个字节.\nSSID的磁场电流的长度: "246var MSG_INVALID_FILE_STR = "无效件.";247var MSG_REBOOT_SECONDS_REMAINS1 = '';248var MSG_REBOOT_SECONDS_REMAINS2 = '秒';...

Full Screen

Full Screen

wxapi.py

Source:wxapi.py Github

copy

Full Screen

...151 filepath = os.path.join(folder, '../', "data/text_reply.yaml")152 with open(filepath, "r") as f:153 result = yaml.load(f)154 return result155 def receive_msg(self, msg):156 root = etree.fromstring(msg)157 msg_type = root.xpath('.//MsgType')[0].text158 if msg_type == "event":159 return self.receive_event_msg(msg)160 elif msg_type == "text":161 return self.receive_text_msg(msg)162 elif msg_type == "image":163 return self.receive_image_msg(msg)164 elif msg_type == "voice":165 return self.receive_voice_msg(msg)166 elif msg_type == "video":167 return self.receive_video_msg(msg)168 elif msg_type == "shortvideo":169 return self.receive_shortvideo_msg(msg)170 elif msg_type == "location":171 return self.receive_location_msg(msg)172 elif msg_type == "link":173 return self.receive_link_msg(msg)174 elif msg_type == "music":175 return self.receive_music_msg(msg)176 elif msg_type == "news":177 return self.receive_news_msg(msg)178 def receive_text_msg(self, msg):179 print(msg)180 root = etree.fromstring(msg)181 to_user = root.xpath('.//ToUserName')[0].text182 from_user = root.xpath('.//FromUserName')[0].text183 msg_type = root.xpath('.//MsgType')[0].text184 msg_id = root.xpath('.//MsgId')[0].text185 content = root.xpath('.//Content')[0].text186 timestamp = root.xpath('.//CreateTime')[0].text187 msg = TextMsg(from_user, to_user, timestamp,188 content, msg_id)189 return msg190 def create_text_msg(self, from_user, to_user, content):191 timestamp = int(time.time())192 xml_form = """193 <xml>194 <ToUserName><![CDATA[{to_user}]]></ToUserName>195 <FromUserName><![CDATA[{from_user}]]></FromUserName>196 <CreateTime>{timestamp}</CreateTime>197 <MsgType><![CDATA[text]]></MsgType>198 <Content><![CDATA[{content}]]></Content>199 </xml>200 """.format(to_user=to_user, from_user=from_user,201 timestamp=timestamp, content=content)202 return xml_form203 def receive_event_msg(self, msg):204 print(msg)205 root = etree.fromstring(msg)206 to_user = root.xpath('.//ToUserName')[0].text207 from_user = root.xpath('.//FromUserName')[0].text208 msg_type = root.xpath('.//MsgType')[0].text209 event = root.xpath('.//Event')[0].text210 timestamp = root.xpath('.//CreateTime')[0].text211 if event == "subscribe" or event == "unsubscribe":212 msg = EventMsg(from_user, to_user, timestamp, event)213 return msg214 if event == "SCAN":215 pass216 if event == "LOCATION":217 pass218 if event == "CLICK":219 pass220 return result221 def receive_image_msg(self, msg):222 print(msg)223 root = etree.fromstring(msg)224 to_user = root.xpath('.//ToUserName')[0].text225 from_user = root.xpath('.//FromUserName')[0].text226 msg_type = root.xpath('.//MsgType')[0].text227 msg_id = root.xpath('.//MsgId')[0].text228 pic_url = root.xpath('.//PicUrl')[0].text229 media_id = root.xpath('.//MediaId')[0].text230 timestamp = root.xpath('.//CreateTime')[0].text231 msg = ImageMsg(from_user, to_user, timestamp,232 pic_url, media_id, msg_id)233 return msg234 def receive_voice_msg(self, msg):235 print(msg)236 root = etree.fromstring(msg)237 to_user = root.xpath('.//ToUserName')[0].text238 from_user = root.xpath('.//FromUserName')[0].text239 msg_type = root.xpath('.//MsgType')[0].text240 msg_id = root.xpath('.//MsgId')[0].text241 media_id = root.xpath('.//MediaId')[0].text242 timestamp = root.xpath('.//CreateTime')[0].text243 vformat = root.xpath('.//Format')[0].text244 msg = VoiceMsg(from_user, to_user, timestamp,245 media_id, vformat, msg_id)246 return msg247 def receive_video_msg(self, msg):248 print(msg)249 root = etree.fromstring(msg)250 to_user = root.xpath('.//ToUserName')[0].text251 from_user = root.xpath('.//FromUserName')[0].text252 msg_type = root.xpath('.//MsgType')[0].text253 msg_id = root.xpath('.//MsgId')[0].text254 media_id = root.xpath('.//MediaId')[0].text255 timestamp = root.xpath('.//CreateTime')[0].text256 thumb_id = root.xpath('.//ThumbMediaId')[0].text257 msg = VideoMsg(from_user, to_user, timestamp,258 media_id, thumb_id, msg_id)259 return msg260 def receive_shortvideo_msg(self, msg):261 print(msg)262 root = etree.fromstring(msg)263 to_user = root.xpath('.//ToUserName')[0].text264 from_user = root.xpath('.//FromUserName')[0].text265 msg_type = root.xpath('.//MsgType')[0].text266 msg_id = root.xpath('.//MsgId')[0].text267 media_id = root.xpath('.//MediaId')[0].text268 timestamp = root.xpath('.//CreateTime')[0].text269 thumb_id = root.xpath('.//ThumbMediaId')[0].text270 msg = ShortvideoMsg(from_user, to_user, timestamp,271 media_id, thumb_id, msg_id)272 return msg273 def receive_music_msg(self, msg):274 print(msg)275 pass276 def receive_location_msg(self, msg):277 print(msg)278 root = etree.fromstring(msg)279 to_user = root.xpath('.//ToUserName')[0].text280 from_user = root.xpath('.//FromUserName')[0].text281 msg_type = root.xpath('.//MsgType')[0].text282 msg_id = root.xpath('.//MsgId')[0].text283 location_x = root.xpath('.//Location_X')[0].text284 location_y = root.xpath('.//Location_Y')[0].text285 timestamp = root.xpath('.//CreateTime')[0].text286 scale = root.xpath('.//Scale')[0].text287 label = root.xpath('.//Label')[0].text288 msg = LocationMsg(from_user, to_user, timestamp,289 location_x, location_y, scale, label, msg_id)290 return msg291 def receive_link_msg(self, msg):292 print(msg)293 root = etree.fromstring(msg)294 to_user = root.xpath('.//ToUserName')[0].text295 from_user = root.xpath('.//FromUserName')[0].text296 msg_type = root.xpath('.//MsgType')[0].text297 msg_id = root.xpath('.//MsgId')[0].text298 timestamp = root.xpath('.//CreateTime')[0].text299 title = root.xpath('.//Title')[0].text300 desc = root.xpath('.//Description')[0].text301 url = root.xpath('.//Url')[0].text302 msg = ShortvideoMsg(from_user, to_user, timestamp,303 title, desc, url, msg_id)304 return msg305 def receive_news_msg(self, msg):306 print(msg)307 pass308 def create_menu(self):309 url = WXAPI_URL + "/menu/create?access_token={}".format(self.token)310 body = json.dumps({311 "button":[312 {313 "type":"click",314 "name":"今日歌曲",315 "key":"V1001_TODAY_MUSIC"316 },317 {318 "name":"菜单",319 "sub_button":[...

Full Screen

Full Screen

uchar.js

Source:uchar.js Github

copy

Full Screen

1goog.provide('goog.i18n.uChar'); 2goog.i18n.uChar.charData_ = null; 3goog.i18n.uChar.toHexString = function(ch) { 4 var chCode = goog.i18n.uChar.toCharCode(ch); 5 var chCodeStr = 'U+' + goog.i18n.uChar.padString_(chCode.toString(16).toUpperCase(), 4, '0'); 6 return chCodeStr; 7}; 8goog.i18n.uChar.padString_ = function(str, length, ch) { 9 while(str.length < length) { 10 str = ch + str; 11 } 12 return str; 13}; 14goog.i18n.uChar.toCharCode = function(ch) { 15 var chCode = ch.charCodeAt(0); 16 if(chCode >= 0xD800 && chCode <= 0xDBFF) { 17 var chCode2 = ch.charCodeAt(1); 18 chCode =(chCode - 0xD800) * 0x400 + chCode2 - 0xDC00 + 0x10000; 19 } 20 return chCode; 21}; 22goog.i18n.uChar.fromCharCode = function(code) { 23 if(! code || code > 0x10FFFF) { 24 return null; 25 } else if(code >= 0x10000) { 26 var hi = Math.floor((code - 0x10000) / 0x400) + 0xD800; 27 var lo =(code - 0x10000) % 0x400 + 0xDC00; 28 return String.fromCharCode(hi) + String.fromCharCode(lo); 29 } else { 30 return String.fromCharCode(code); 31 } 32}; 33goog.i18n.uChar.toName = function(ch) { 34 if(! goog.i18n.uChar.charData_) { 35 goog.i18n.uChar.createCharData(); 36 } 37 var names = goog.i18n.uChar.charData_; 38 var chCode = goog.i18n.uChar.toCharCode(ch); 39 var chCodeStr = chCode + ''; 40 if(ch in names) { 41 return names[ch]; 42 } else if(chCodeStr in names) { 43 return names[chCode]; 44 } else if(0xFE00 <= chCode && chCode <= 0xFE0F || 0xE0100 <= chCode && chCode <= 0xE01EF) { 45 var seqnum; 46 if(0xFE00 <= chCode && chCode <= 0xFE0F) { 47 seqnum = chCode - 0xFDFF; 48 } else { 49 seqnum = chCode - 0xE00EF; 50 } 51 var MSG_VARIATION_SELECTOR_SEQNUM = goog.getMsg('Variation Selector - {$seqnum}', { 'seqnum': seqnum }); 52 return MSG_VARIATION_SELECTOR_SEQNUM; 53 } 54 return null; 55}; 56goog.i18n.uChar.createCharData = function() { 57 var MSG_CP_ARABIC_SIGN_SANAH = goog.getMsg('Arabic Sign Sanah'); 58 var MSG_CP_CANADIAN_SYLLABICS_HYPHEN = goog.getMsg('Canadian Syllabics Hyphen'); 59 var MSG_CP_ARABIC_SIGN_SAFHA = goog.getMsg('Arabic Sign Safha'); 60 var MSG_CP_ARABIC_FOOTNOTE_MARKER = goog.getMsg('Arabic Footnote Marker'); 61 var MSG_CP_FOUR_PER_EM_SPACE = goog.getMsg('Four-per-em Space'); 62 var MSG_CP_THREE_PER_EM_SPACE = goog.getMsg('Three-per-em Space'); 63 var MSG_CP_FIGURE_SPACE = goog.getMsg('Figure Space'); 64 var MSG_CP_MONGOLIAN_SOFT_HYPHEN = goog.getMsg('Mongolian Soft Hyphen'); 65 var MSG_CP_THIN_SPACE = goog.getMsg('Thin Space'); 66 var MSG_CP_SOFT_HYPHEN = goog.getMsg('Soft Hyphen'); 67 var MSG_CP_ZERO_WIDTH_SPACE = goog.getMsg('Zero Width Space'); 68 var MSG_CP_ARMENIAN_HYPHEN = goog.getMsg('Armenian Hyphen'); 69 var MSG_CP_ZERO_WIDTH_JOINER = goog.getMsg('Zero Width Joiner'); 70 var MSG_CP_EM_SPACE = goog.getMsg('Em Space'); 71 var MSG_CP_SYRIAC_ABBREVIATION_MARK = goog.getMsg('Syriac Abbreviation Mark'); 72 var MSG_CP_MONGOLIAN_VOWEL_SEPARATOR = goog.getMsg('Mongolian Vowel Separator'); 73 var MSG_CP_NON_BREAKING_HYPHEN = goog.getMsg('Non-breaking Hyphen'); 74 var MSG_CP_HYPHEN = goog.getMsg('Hyphen'); 75 var MSG_CP_EM_QUAD = goog.getMsg('Em Quad'); 76 var MSG_CP_EN_SPACE = goog.getMsg('En Space'); 77 var MSG_CP_HORIZONTAL_BAR = goog.getMsg('Horizontal Bar'); 78 var MSG_CP_EM_DASH = goog.getMsg('Em Dash'); 79 var MSG_CP_DOUBLE_OBLIQUE_HYPHEN = goog.getMsg('Double Oblique Hyphen'); 80 var MSG_CP_MUSICAL_SYMBOL_END_PHRASE = goog.getMsg('Musical Symbol End Phrase'); 81 var MSG_CP_MEDIUM_MATHEMATICAL_SPACE = goog.getMsg('Medium Mathematical Space'); 82 var MSG_CP_WAVE_DASH = goog.getMsg('Wave Dash'); 83 var MSG_CP_SPACE = goog.getMsg('Space'); 84 var MSG_CP_HYPHEN_WITH_DIAERESIS = goog.getMsg('Hyphen With Diaeresis'); 85 var MSG_CP_EN_QUAD = goog.getMsg('En Quad'); 86 var MSG_CP_RIGHT_TO_LEFT_EMBEDDING = goog.getMsg('Right-to-left Embedding'); 87 var MSG_CP_SIX_PER_EM_SPACE = goog.getMsg('Six-per-em Space'); 88 var MSG_CP_HYPHEN_MINUS = goog.getMsg('Hyphen-minus'); 89 var MSG_CP_POP_DIRECTIONAL_FORMATTING = goog.getMsg('Pop Directional Formatting'); 90 var MSG_CP_NARROW_NO_BREAK_SPACE = goog.getMsg('Narrow No-break Space'); 91 var MSG_CP_RIGHT_TO_LEFT_OVERRIDE = goog.getMsg('Right-to-left Override'); 92 var MSG_CP_PRESENTATION_FORM_FOR_VERTICAL_EM_DASH = goog.getMsg('Presentation Form For Vertical Em Dash'); 93 var MSG_CP_WAVY_DASH = goog.getMsg('Wavy Dash'); 94 var MSG_CP_PRESENTATION_FORM_FOR_VERTICAL_EN_DASH = goog.getMsg('Presentation Form For Vertical En Dash'); 95 var MSG_CP_KHMER_VOWEL_INHERENT_AA = goog.getMsg('Khmer Vowel Inherent Aa'); 96 var MSG_CP_KHMER_VOWEL_INHERENT_AQ = goog.getMsg('Khmer Vowel Inherent Aq'); 97 var MSG_CP_PUNCTUATION_SPACE = goog.getMsg('Punctuation Space'); 98 var MSG_CP_HALFWIDTH_HANGUL_FILLER = goog.getMsg('Halfwidth Hangul Filler'); 99 var MSG_CP_KAITHI_NUMBER_SIGN = goog.getMsg('Kaithi Number Sign'); 100 var MSG_CP_LEFT_TO_RIGHT_EMBEDDING = goog.getMsg('Left-to-right Embedding'); 101 var MSG_CP_HEBREW_PUNCTUATION_MAQAF = goog.getMsg('Hebrew Punctuation Maqaf'); 102 var MSG_CP_IDEOGRAPHIC_SPACE = goog.getMsg('Ideographic Space'); 103 var MSG_CP_HAIR_SPACE = goog.getMsg('Hair Space'); 104 var MSG_CP_NO_BREAK_SPACE = goog.getMsg('No-break Space'); 105 var MSG_CP_FULLWIDTH_HYPHEN_MINUS = goog.getMsg('Fullwidth Hyphen-minus'); 106 var MSG_CP_PARAGRAPH_SEPARATOR = goog.getMsg('Paragraph Separator'); 107 var MSG_CP_LEFT_TO_RIGHT_OVERRIDE = goog.getMsg('Left-to-right Override'); 108 var MSG_CP_SMALL_HYPHEN_MINUS = goog.getMsg('Small Hyphen-minus'); 109 var MSG_CP_COMBINING_GRAPHEME_JOINER = goog.getMsg('Combining Grapheme Joiner'); 110 var MSG_CP_ZERO_WIDTH_NON_JOINER = goog.getMsg('Zero Width Non-joiner'); 111 var MSG_CP_MUSICAL_SYMBOL_BEGIN_PHRASE = goog.getMsg('Musical Symbol Begin Phrase'); 112 var MSG_CP_ARABIC_NUMBER_SIGN = goog.getMsg('Arabic Number Sign'); 113 var MSG_CP_RIGHT_TO_LEFT_MARK = goog.getMsg('Right-to-left Mark'); 114 var MSG_CP_OGHAM_SPACE_MARK = goog.getMsg('Ogham Space Mark'); 115 var MSG_CP_SMALL_EM_DASH = goog.getMsg('Small Em Dash'); 116 var MSG_CP_LEFT_TO_RIGHT_MARK = goog.getMsg('Left-to-right Mark'); 117 var MSG_CP_ARABIC_END_OF_AYAH = goog.getMsg('Arabic End Of Ayah'); 118 var MSG_CP_HANGUL_CHOSEONG_FILLER = goog.getMsg('Hangul Choseong Filler'); 119 var MSG_CP_HANGUL_FILLER = goog.getMsg('Hangul Filler'); 120 var MSG_CP_FUNCTION_APPLICATION = goog.getMsg('Function Application'); 121 var MSG_CP_HANGUL_JUNGSEONG_FILLER = goog.getMsg('Hangul Jungseong Filler'); 122 var MSG_CP_INVISIBLE_SEPARATOR = goog.getMsg('Invisible Separator'); 123 var MSG_CP_INVISIBLE_TIMES = goog.getMsg('Invisible Times'); 124 var MSG_CP_INVISIBLE_PLUS = goog.getMsg('Invisible Plus'); 125 var MSG_CP_WORD_JOINER = goog.getMsg('Word Joiner'); 126 var MSG_CP_LINE_SEPARATOR = goog.getMsg('Line Separator'); 127 var MSG_CP_KATAKANA_HIRAGANA_DOUBLE_HYPHEN = goog.getMsg('Katakana-hiragana Double Hyphen'); 128 var MSG_CP_EN_DASH = goog.getMsg('En Dash'); 129 var MSG_CP_MUSICAL_SYMBOL_BEGIN_BEAM = goog.getMsg('Musical Symbol Begin Beam'); 130 var MSG_CP_FIGURE_DASH = goog.getMsg('Figure Dash'); 131 var MSG_CP_MUSICAL_SYMBOL_BEGIN_TIE = goog.getMsg('Musical Symbol Begin Tie'); 132 var MSG_CP_MUSICAL_SYMBOL_END_BEAM = goog.getMsg('Musical Symbol End Beam'); 133 var MSG_CP_MUSICAL_SYMBOL_BEGIN_SLUR = goog.getMsg('Musical Symbol Begin Slur'); 134 var MSG_CP_MUSICAL_SYMBOL_END_TIE = goog.getMsg('Musical Symbol End Tie'); 135 var MSG_CP_INTERLINEAR_ANNOTATION_ANCHOR = goog.getMsg('Interlinear Annotation Anchor'); 136 var MSG_CP_MUSICAL_SYMBOL_END_SLUR = goog.getMsg('Musical Symbol End Slur'); 137 var MSG_CP_INTERLINEAR_ANNOTATION_TERMINATOR = goog.getMsg('Interlinear Annotation Terminator'); 138 var MSG_CP_INTERLINEAR_ANNOTATION_SEPARATOR = goog.getMsg('Interlinear Annotation Separator'); 139 var MSG_CP_ZERO_WIDTH_NO_BREAK_SPACE = goog.getMsg('Zero Width No-break Space'); 140 goog.i18n.uChar.charData_ = { 141 '\u0601': MSG_CP_ARABIC_SIGN_SANAH, 142 '\u1400': MSG_CP_CANADIAN_SYLLABICS_HYPHEN, 143 '\u0603': MSG_CP_ARABIC_SIGN_SAFHA, 144 '\u0602': MSG_CP_ARABIC_FOOTNOTE_MARKER, 145 '\u2005': MSG_CP_FOUR_PER_EM_SPACE, 146 '\u2004': MSG_CP_THREE_PER_EM_SPACE, 147 '\u2007': MSG_CP_FIGURE_SPACE, 148 '\u1806': MSG_CP_MONGOLIAN_SOFT_HYPHEN, 149 '\u2009': MSG_CP_THIN_SPACE, 150 '\u00AD': MSG_CP_SOFT_HYPHEN, 151 '\u200B': MSG_CP_ZERO_WIDTH_SPACE, 152 '\u058A': MSG_CP_ARMENIAN_HYPHEN, 153 '\u200D': MSG_CP_ZERO_WIDTH_JOINER, 154 '\u2003': MSG_CP_EM_SPACE, 155 '\u070F': MSG_CP_SYRIAC_ABBREVIATION_MARK, 156 '\u180E': MSG_CP_MONGOLIAN_VOWEL_SEPARATOR, 157 '\u2011': MSG_CP_NON_BREAKING_HYPHEN, 158 '\u2010': MSG_CP_HYPHEN, 159 '\u2001': MSG_CP_EM_QUAD, 160 '\u2002': MSG_CP_EN_SPACE, 161 '\u2015': MSG_CP_HORIZONTAL_BAR, 162 '\u2014': MSG_CP_EM_DASH, 163 '\u2E17': MSG_CP_DOUBLE_OBLIQUE_HYPHEN, 164 '\u1D17A': MSG_CP_MUSICAL_SYMBOL_END_PHRASE, 165 '\u205F': MSG_CP_MEDIUM_MATHEMATICAL_SPACE, 166 '\u301C': MSG_CP_WAVE_DASH, 167 ' ': MSG_CP_SPACE, 168 '\u2E1A': MSG_CP_HYPHEN_WITH_DIAERESIS, 169 '\u2000': MSG_CP_EN_QUAD, 170 '\u202B': MSG_CP_RIGHT_TO_LEFT_EMBEDDING, 171 '\u2006': MSG_CP_SIX_PER_EM_SPACE, 172 '-': MSG_CP_HYPHEN_MINUS, 173 '\u202C': MSG_CP_POP_DIRECTIONAL_FORMATTING, 174 '\u202F': MSG_CP_NARROW_NO_BREAK_SPACE, 175 '\u202E': MSG_CP_RIGHT_TO_LEFT_OVERRIDE, 176 '\uFE31': MSG_CP_PRESENTATION_FORM_FOR_VERTICAL_EM_DASH, 177 '\u3030': MSG_CP_WAVY_DASH, 178 '\uFE32': MSG_CP_PRESENTATION_FORM_FOR_VERTICAL_EN_DASH, 179 '\u17B5': MSG_CP_KHMER_VOWEL_INHERENT_AA, 180 '\u17B4': MSG_CP_KHMER_VOWEL_INHERENT_AQ, 181 '\u2008': MSG_CP_PUNCTUATION_SPACE, 182 '\uFFA0': MSG_CP_HALFWIDTH_HANGUL_FILLER, 183 '\u110BD': MSG_CP_KAITHI_NUMBER_SIGN, 184 '\u202A': MSG_CP_LEFT_TO_RIGHT_EMBEDDING, 185 '\u05BE': MSG_CP_HEBREW_PUNCTUATION_MAQAF, 186 '\u3000': MSG_CP_IDEOGRAPHIC_SPACE, 187 '\u200A': MSG_CP_HAIR_SPACE, 188 '\u00A0': MSG_CP_NO_BREAK_SPACE, 189 '\uFF0D': MSG_CP_FULLWIDTH_HYPHEN_MINUS, 190 '8233': MSG_CP_PARAGRAPH_SEPARATOR, 191 '\u202D': MSG_CP_LEFT_TO_RIGHT_OVERRIDE, 192 '\uFE63': MSG_CP_SMALL_HYPHEN_MINUS, 193 '\u034F': MSG_CP_COMBINING_GRAPHEME_JOINER, 194 '\u200C': MSG_CP_ZERO_WIDTH_NON_JOINER, 195 '\u1D179': MSG_CP_MUSICAL_SYMBOL_BEGIN_PHRASE, 196 '\u0600': MSG_CP_ARABIC_NUMBER_SIGN, 197 '\u200F': MSG_CP_RIGHT_TO_LEFT_MARK, 198 '\u1680': MSG_CP_OGHAM_SPACE_MARK, 199 '\uFE58': MSG_CP_SMALL_EM_DASH, 200 '\u200E': MSG_CP_LEFT_TO_RIGHT_MARK, 201 '\u06DD': MSG_CP_ARABIC_END_OF_AYAH, 202 '\u115F': MSG_CP_HANGUL_CHOSEONG_FILLER, 203 '\u3164': MSG_CP_HANGUL_FILLER, 204 '\u2061': MSG_CP_FUNCTION_APPLICATION, 205 '\u1160': MSG_CP_HANGUL_JUNGSEONG_FILLER, 206 '\u2063': MSG_CP_INVISIBLE_SEPARATOR, 207 '\u2062': MSG_CP_INVISIBLE_TIMES, 208 '\u2064': MSG_CP_INVISIBLE_PLUS, 209 '\u2060': MSG_CP_WORD_JOINER, 210 '8232': MSG_CP_LINE_SEPARATOR, 211 '\u30A0': MSG_CP_KATAKANA_HIRAGANA_DOUBLE_HYPHEN, 212 '\u2013': MSG_CP_EN_DASH, 213 '\u1D173': MSG_CP_MUSICAL_SYMBOL_BEGIN_BEAM, 214 '\u2012': MSG_CP_FIGURE_DASH, 215 '\u1D175': MSG_CP_MUSICAL_SYMBOL_BEGIN_TIE, 216 '\u1D174': MSG_CP_MUSICAL_SYMBOL_END_BEAM, 217 '\u1D177': MSG_CP_MUSICAL_SYMBOL_BEGIN_SLUR, 218 '\u1D176': MSG_CP_MUSICAL_SYMBOL_END_TIE, 219 '\uFFF9': MSG_CP_INTERLINEAR_ANNOTATION_ANCHOR, 220 '\u1D178': MSG_CP_MUSICAL_SYMBOL_END_SLUR, 221 '\uFFFB': MSG_CP_INTERLINEAR_ANNOTATION_TERMINATOR, 222 '\uFFFA': MSG_CP_INTERLINEAR_ANNOTATION_SEPARATOR, 223 '\uFEFF': MSG_CP_ZERO_WIDTH_NO_BREAK_SPACE 224 }; ...

Full Screen

Full Screen

gameServer.py

Source:gameServer.py Github

copy

Full Screen

1from twisted.internet.protocol import Factory,Protocol2from twisted.internet import reactor3from support import *4import json5from messageType import *6import messageHandle7from room import *8class ClientHandle(Protocol):9 def __init__(self):10 self.handshake = False11 self.GUID = "258EAFA5-E914-47DA-95CA-C5AB0DC85B11"12 self.path = "/"13 self.index = 014 self.clientName = "" 15 16 def dataReceived(self, data): 17 if self.handshake == False: 18 headers = {}19 buffer = bytes.decode(data) 20 21 if buffer.find('\r\n\r\n') != -1: 22 header, data = buffer.split('\r\n\r\n', 1) 23 for line in header.split("\r\n")[1:]: 24 key, value = line.split(": ", 1) 25 headers[key] = value 26 27 headers["Location"] = ("ws://%s%s" %(headers["Host"], self.path)) 28 key = headers['Sec-WebSocket-Key'] 29 token = b64encode(hashlib.sha1(str.encode(str(key + self.GUID))).digest()) 30 31 handshake='HTTP/1.1 101 WebSocket Protocol Hybi-10\r\n\32Upgrade: WebSocket\r\n\33Connection: Upgrade\r\n\34Sec-WebSocket-Accept: %s\r\n\r\n' %(bytes.decode(token))35 36 self.transport.write(str.encode(str(handshake))) 37 self.handshake = True 38 print ('Socket %s Handshaken with %s success!' %(self.index, self.getId())) 39 #self.sendMessage('Welcome, ' + self.name + ' !') 40 else: 41 if len(data) <= 0: 42 return 43 44 #print 'Data before handle: ',data45 try:46 headerLength,codeLength = get_datalength(data)47 except Exception:48 print 'data error'49 return50 51 52 if len(data) - headerLength < codeLength :53 print 'Msg bad'54 return 55 else : 56 buffer_utf8 = parse_data(data) #解析出UTF-8编码的数据 57 msg_unicode = str(buffer_utf8[:codeLength]).decode('utf-8', 'ignore') #解码成unicode58 59 #print 'MsgData: %s' % (msg_unicode)60 self.processMessage(msg_unicode)61 62 remainData = data[headerLength+codeLength:]63 self.dataReceived(remainData)64 65 66 67 def getId(self):68 return str(self.transport.getPeer())69 70 def connectionMade(self):71 print "New connection from",self.getId()72 self.factory.addClient(self)73 74 def connectionLost(self, reason):75 print "connection lose"76 self.factory.delClient(self)77 78 def sendSingleMessage(self,msg):79 newMsg = processMessage(msg)80 self.transport.write(newMsg)81 82 def sendMessage(self,name,msg): 83 newMsg = processMessage(msg)84 #print "Send msg: %s" %(newMsg)85 self.factory.sendMsg(name,newMsg) #以UTF-8编码发送数据86 87 def sendToAll(self,msg):88 newMsg = processMessage(msg)89 #print "Send msg: %s" %(newMsg)90 self.factory.sendAll(newMsg)91 92 def sendToOther(self,name,msg): 93 newMsg = processMessage(msg)94 #print "Send msg: %s" %(newMsg)95 self.factory.sendToOther(name,newMsg)96 97 def sendToAllOther(self,name,msg):98 newMsg = processMessage(msg)99 #print "Send msg: %s" %(newMsg)100 self.factory.sendToAllOther(name,newMsg)101 102 def processMessage(self,msg):103 try:104 msgData = json.loads(msg)105 except Exception:106 print 'catch exception in json.loads(msg)'107 return108 109 if msgData['MsgType'] == msgType['Login']:110 result = messageHandle.processLogin(msgData['Data'])111 code = result[0]112 if code==1:113 self.clientName = msgData['Data']['Name']114 self.factory.addClientMap(msgData['Data']['Name'],self)115 116 returnMsg = json.dumps(result[1])117 self.sendSingleMessage(returnMsg)118 #self.sendMessage(msgData['Data']['Name'],returnMsg)119 elif msgData['MsgType'] == msgType['Account_Info']:120 code = messageHandle.processAccountInfo(msgData['Name'])121 returnMsg = json.dumps(code)122 self.sendMessage(msgData['Name'],returnMsg)123 elif msgData['MsgType'] == msgType['ChatSend']:124 result = messageHandle.processChatSend(msgData)125 code = result[0]126 if code:pass127 128 returnMsg = json.dumps(result[1])129 self.sendToOther(msgData['Receiver'],returnMsg)130 elif msgData['MsgType'] == msgType['StartSingleGame']:131 result = messageHandle.processStartSingleGame(self.factory,msgData)132 code = result[0]133 if code:pass134 135 returnMsg = json.dumps(result[1])136 enterPlayerMsg = json.dumps(result[2])137 self.sendMessage(msgData['AccountName'],returnMsg)138 self.sendToAllOther(msgData['AccountName'], enterPlayerMsg)139 elif msgData['MsgType'] == msgType['Move']:140 result = messageHandle.processPlayerMove(msgData)141 code = result[0]142 if code:pass143 144 returnMsg = json.dumps(result[1])145 self.sendToAllOther(msgData['AccountName'], returnMsg)146 elif msgData['MsgType'] == msgType['Divide']:147 result = messageHandle.processPlayerDivide(msgData)148 code = result[0]149 if code:pass150 151 returnMsg = json.dumps(result[1])152 self.sendToAllOther(msgData['AccountName'], returnMsg)153 elif msgData['MsgType'] == msgType['UpdatePosition']:154 result = messageHandle.processUpdatePlayer(self.factory, msgData)155 code = result[0]156 if code:157 returnMsg = json.dumps(result[1])158 self.sendToAllOther(msgData['AccountName'], returnMsg)159 elif msgData['MsgType'] == msgType['SpitSpore']:160 result = messageHandle.processSpitSpore(self.factory, msgData)161 code = result[0]162 if code:163 returnMsg = json.dumps(result[1])164 self.sendToAll(returnMsg)165 elif msgData['MsgType'] == msgType['PlayerConcentrate']:166 result = messageHandle.processPlayerConcentrate(msgData)167 code = result[0]168 if code:pass169 170 returnMsg = json.dumps(result[1])171 self.sendToAllOther(msgData['AccountName'], returnMsg)172 elif msgData['MsgType'] == msgType['UpdateSpore']:173 messageHandle.processUpdateSpore(self.factory, msgData)174 elif msgData['MsgType'] == msgType['EatPrick']:175 messageHandle.processEatPrick(self.factory, msgData)176 177 def serverSynMessage(self,msg):178 returnMsg = json.dumps(msg)179 self.sendMessage(self.clientName, returnMsg)180 181class GameServer(Factory):182 protocol = ClientHandle183 184 def __init__(self):185 self.clients = []186 self.clientMap = {}187 self.roomMap = {}188 self.roomSerialID = 0189 190 def addClient(self,newClient):191 self.clients.append(newClient)192 193 def delClient(self,client):194 self.clients.remove(client)195 if self.clientMap.has_key(client.clientName):196 self.clientMap.pop(client.clientName)197 198 def addClientMap(self,name,client):199 self.clientMap[name] = client200 201 def sendAll(self,message):202 for proto in self.clients:203 proto.transport.write(message)204 205 def sendToOther(self,name,message):206 if self.clientMap.has_key(name):207 self.clientMap[name].transport.write(message)208 209 def sendToAllOther(self,name,message):210 for key,client in self.clientMap.items():211 if key != name:212 client.transport.write(message)213 214 def sendMsg(self,name,message):215 if self.clientMap.has_key(name):216 self.clientMap[name].transport.write(message)217 218 def addRoom(self,type):219 self.roomMap[self.roomSerialID] = Room(self.roomSerialID,type,self)220 self.roomMap[self.roomSerialID].start()221 self.roomSerialID +=1222 return self.roomSerialID-1223 224 def removeRoom(self,roomID):225 self.roomMap.pop(roomID)226 227factory = GameServer() 228reactor.listenTCP(8766,factory) 229print "GameServer run..." 230reactor.run() 231 232 233 234 235 236 237 238 ...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run green automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful