Beispiel #1
0
 def __init__(self, dataprotocl=DataPackProtoc()):
     '''初始化
     '''
     protocols.ServerFactory.__init__(self)
     self.service = None
     self.connmanager = ConnectionManager()
     self.dataprotocl = dataprotocl
Beispiel #2
0
import netapp
import gatenodeapp
from gfirefly.server.globalobject import GlobalObject
from gfirefly.netconnect.datapack import DataPackProtoc


def conn_made(conn):
    '''当连接建立时调用的方法'''
    if not GlobalObject().netfactory.connmanager.hasConnection(conn.transport.sessionno):
        queue_num = GlobalObject().netfactory.connmanager.queue_num
        GlobalObject().netfactory.pushObject(1326, str(queue_num), [conn.transport.sessionno])
    return


def conn_lost(conn):
    dynamic_id = conn.transport.sessionno
    if dynamic_id != 0:
        GlobalObject().remote['gate'].net_conn_lost_remote_noresult(dynamic_id)

    # pop queue conn to normal conn, when conn lost
    conn = GlobalObject().netfactory.connmanager.pop_queue()
    if conn:
        GlobalObject().netfactory.pushObject(1326, str(0), [conn.instance.transport.sessionno])


GlobalObject().netfactory.doConnectionLost = conn_lost
GlobalObject().netfactory.doConnectionMade = conn_made
dataprotocl = DataPackProtoc(0, 0, 0, 0, 0, 0)
GlobalObject().netfactory.setDataProtocl(dataprotocl)
Beispiel #3
0
#coding:utf8
'''
Created on 2013-8-14

@author: lan (www.9miao.com)
'''
from gfirefly.server.globalobject import GlobalObject
from gfirefly.netconnect.datapack import DataPackProtoc


def callWhenConnLost(conn):
    dynamicId = conn.transport.sessionno
    GlobalObject().remote['gate'].callRemote("netconnlost", dynamicId)


GlobalObject().netfactory.doConnectionLost = callWhenConnLost
dataprotocl = DataPackProtoc(78, 37, 38, 48, 9, 0)
GlobalObject().netfactory.setDataProtocl(dataprotocl)


def loadModule():
    import netapp
    import gatenodeapp
Beispiel #4
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Created on 2015/5/8
@author: Linwencai
"""
from gfirefly.server.globalobject import GlobalObject
from gfirefly.netconnect.datapack import DataPackProtoc

# 定义包头
dataprotocl = DataPackProtoc(1, 2, 3, 4, 5, 6)
GlobalObject().netfactory.setDataProtocl(dataprotocl)


def callWhenConnCreate(conn):
    """ 连接建立时回调
    """
    return


GlobalObject().netfactory.doConnectionMade = callWhenConnCreate


def callWhenConnLost(conn):
    """ 连接断开时回调
    """
    dynamicId = conn.transport.sessionno
    GlobalObject().remote['gate'].callRemote("netconnlost", dynamicId)
    return