예제 #1
0
def sendMessage_1003(_conn, request_proto):
    '''发送聊天消息'''
#    from protoFile.chat import sendMessage1003_pb2
#    from core.Item import Item
    argument = sendMessage1003_pb2.chatConectingRequest()
    argument.ParseFromString(request_proto)
    response = sendMessage1003_pb2.chatConectingResponse()
    
    dynamicId = _conn.transport.sessionno
    characterId = argument.id #当前角色id
    topic = argument.topic #频道号  
    tonickname=argument.chatOjbect #角色昵称
    content = argument.content #内容
    linkData = [] #聊天连接信息
    for _item in argument.linkData:
        item = {}
        item['chatEquipType'] = _item.chatEquipType
        item['id'] = _item.id
        item['name'] = _item.name
#        try:
#            item1=Item(id=_item.id)
#        except Exception:
#            linkData.append(item)
#            continue
#        item['itemInfo']=item1
#        linkData.append(item)
#        del item1
        
    
    data = chat.sendMessage(dynamicId, characterId, topic, content,linkData,tonickname)
    response.result = data.get('result',False)
    response.message = data.get('message','')
    return response.SerializeToString()
예제 #2
0
def sendMessage_1003(_conn, request_proto):
    '''发送聊天消息'''
    #    from protoFile.chat import sendMessage1003_pb2
    #    from core.Item import Item
    argument = sendMessage1003_pb2.chatConectingRequest()
    argument.ParseFromString(request_proto)
    response = sendMessage1003_pb2.chatConectingResponse()

    dynamicId = _conn.transport.sessionno
    characterId = argument.id  #当前角色id
    topic = argument.topic  #频道号
    tonickname = argument.chatOjbect  #角色昵称
    content = argument.content  #内容
    linkData = []  #聊天连接信息
    for _item in argument.linkData:
        item = {}
        item['chatEquipType'] = _item.chatEquipType
        item['id'] = _item.id
        item['name'] = _item.name
#        try:
#            item1=Item(id=_item.id)
#        except Exception:
#            linkData.append(item)
#            continue
#        item['itemInfo']=item1
#        linkData.append(item)
#        del item1

    data = chat.sendMessage(dynamicId, characterId, topic, content, linkData,
                            tonickname)
    response.result = data.get('result', False)
    response.message = data.get('message', '')
    return response.SerializeToString()
예제 #3
0
def sendMessage_1003(_conn, request_proto):
    '''发送聊天消息'''
    from app.chatServer.core.ChaterManager import ChaterManager
#    from core.Item import Item
    argument = sendMessage1003_pb2.chatConectingRequest()
    argument.ParseFromString(request_proto)
    response = sendMessage1003_pb2.chatConectingResponse()
    
    dynamicId = _conn.transport.sessionno
    characterId = argument.id #当前角色id
    topic = argument.topic #频道号  
    tonickname=argument.chatOjbect #角色昵称
    content = argument.content #内容
    
    chater=ChaterManager().getChaterByCharacterId(characterId)
    if chater.donttalk==0:#不禁言
        linkData = [] #聊天连接信息
        for _item in argument.linkData:
            item = {}
            item['chatEquipType'] = _item.chatEquipType #0物品 1角色 2怪物
            item['id'] = _item.id
            item['name'] = _item.name
            
            if _item.chatEquipType==0:
                item1=Item(id=_item.id)
                item['itemInfo']=item1
#            elif _item.chatEquipType==1:
#                linkData.append(item)
#                continue
            
            linkData.append(item)
        Lt().add(characterId, tonickname, content)
        data = chat.sendMessage(dynamicId, characterId, topic, content,linkData,tonickname)
        response.result = data.get('result',False)
        response.message = data.get('message',u'')
    else:#禁言
        response.result = False
        response.message =Lg().g(644) 
    return response.SerializeToString()