def write(self, data):
        """
        发送数据    True: 成功   else: 失败
        """
        if self.stream.closed():
            return False

        if isinstance(data, self.app.box_class):
            # 打包
            data = data.pack()
        elif isinstance(data, dict):
            data = self.app.box_class(data).pack()

        self.app.events.before_response(self, data)
        for bp in self.app.blueprints:
            bp.events.before_app_response(self, data)

        ret = self.stream.write(data)

        for bp in self.app.blueprints:
            bp.events.after_app_response(self, data, ret)
        self.app.events.after_response(self, data, ret)

        return ret
def write ( self , data ) : if self . stream . closed ( ) : return False if isinstance ( data , self . app . box_class ) : data = data . pack ( ) elif isinstance ( data , dict ) : data = self . app . box_class ( data ) . pack ( ) self . app . events . before_response ( self , data ) for bp in self . app . blueprints : bp . events . before_app_response ( self , data ) ret = self . stream . write ( data ) for bp in self . app . blueprints : bp . events . after_app_response ( self , data , ret ) self . app . events . after_response ( self , data , ret ) return ret
发送数据    True: 成功   else: 失败