github.com/chanxuehong/wechat@v0.0.0-20230222024006-36f0325263cd/mp/dkf/session/event.go (about)

     1  package session
     2  
     3  import (
     4  	"github.com/chanxuehong/wechat/mp/core"
     5  )
     6  
     7  const (
     8  	EventTypeKfCreateSession core.EventType = "kf_create_session" // 接入会话
     9  	EventTypeKfCloseSession  core.EventType = "kf_close_session"  // 关闭会话
    10  	EventTypeKfSwitchSession core.EventType = "kf_switch_session" // 转接会话
    11  )
    12  
    13  type KfCreateSessionEvent struct {
    14  	XMLName struct{} `xml:"xml" json:"-"`
    15  	core.MsgHeader
    16  	EventType core.EventType `xml:"Event"     json:"Event"`
    17  	KfAccount string         `xml:"KfAccount" json:"KfAccount"`
    18  }
    19  
    20  func GetKfCreateSessionEvent(msg *core.MixedMsg) *KfCreateSessionEvent {
    21  	return &KfCreateSessionEvent{
    22  		MsgHeader: msg.MsgHeader,
    23  		EventType: msg.EventType,
    24  		KfAccount: msg.KfAccount,
    25  	}
    26  }
    27  
    28  type KfCloseSessionEvent struct {
    29  	XMLName struct{} `xml:"xml" json:"-"`
    30  	core.MsgHeader
    31  	EventType core.EventType `xml:"Event"     json:"Event"`
    32  	KfAccount string         `xml:"KfAccount" json:"KfAccount"`
    33  }
    34  
    35  func GetKfCloseSessionEvent(msg *core.MixedMsg) *KfCloseSessionEvent {
    36  	return &KfCloseSessionEvent{
    37  		MsgHeader: msg.MsgHeader,
    38  		EventType: msg.EventType,
    39  		KfAccount: msg.KfAccount,
    40  	}
    41  }
    42  
    43  type KfSwitchSessionEvent struct {
    44  	XMLName struct{} `xml:"xml" json:"-"`
    45  	core.MsgHeader
    46  	EventType     core.EventType `xml:"Event"         json:"Event"`
    47  	FromKfAccount string         `xml:"FromKfAccount" json:"FromKfAccount"`
    48  	ToKfAccount   string         `xml:"ToKfAccount"   json:"ToKfAccount"`
    49  }
    50  
    51  func GetKfSwitchSessionEvent(msg *core.MixedMsg) *KfSwitchSessionEvent {
    52  	return &KfSwitchSessionEvent{
    53  		MsgHeader:     msg.MsgHeader,
    54  		EventType:     msg.EventType,
    55  		FromKfAccount: msg.FromKfAccount,
    56  		ToKfAccount:   msg.ToKfAccount,
    57  	}
    58  }