From 8304754203356249cca170a3f01433646b876e9d Mon Sep 17 00:00:00 2001 From: Patrick Peng Sun Date: Sat, 27 May 2017 15:38:14 +1000 Subject: [PATCH] Describe a procedure using data structure and standard functions --- chatSession.go | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/chatSession.go b/chatSession.go index 6007056..07f3784 100644 --- a/chatSession.go +++ b/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 +}