浏览代码

Describe a procedure using data structure and standard functions

master
Patrick Peng Sun 8 年前
父节点
当前提交
8304754203
共有 1 个文件被更改,包括 23 次插入0 次删除
  1. +23
    -0
      chatSession.go

+ 23
- 0
chatSession.go 查看文件

@@ -124,3 +124,26 @@ func deleteSession(openID string) {
}
}
}

//OneMessage a description of what to send /receive
type OneMessage struct {
Type string `json:"Type"` //MessageType
Text string `json:"Text"` //for text messages
Pic MediaID `json:"Pic"`
Voice MediaID `json:"Voice"`
ShortVideo MediaID `json:"ShortVideo"`
Video MediaID `json:"Video"`
}

type initProcFunc func(openid string) (newstate chatState)
type sendProcMsgFunc func(openid string) (newstate chatState)
type recvProcMsgFunc func(openid string, msg OneMessage) (newstate chatState)
type cleanProcFunc func(openid string) (newstate chatState)

//Procedure a description about all procedure
type Procedure struct {
init initProcFunc //init function
send sendProcMsgFunc //function for sending customized message
recv recvProcMsgFunc //function for receiving message, possibly transfer to new state
clean cleanProcFunc //function for cleanning up
}

正在加载...
取消
保存