Parcourir la source

server simplified to use pipelines

master
Patrick Peng Sun il y a 8 ans
Parent
révision
ef469a5c26
1 fichiers modifiés avec 6 ajouts et 24 suppressions
  1. +6
    -24
      server.go

+ 6
- 24
server.go Voir le fichier

@@ -10,7 +10,6 @@ import (
"net/http/httputil"
"net/url"
"os"
"reflect"
"sort"
"strings"
)
@@ -66,33 +65,16 @@ type InWechatMsg struct {
//answerWechatPost distribute PostRequest according to xml body info
func answerWechatPost(w http.ResponseWriter, r *http.Request) {
in, valid := readWechatInput(r)
//reply := "" //nothing
reply := "" //nothing
w.Header().Set("Content-Type", "text/xml; charset=utf-8")

if !valid {
log.Println("Error: Invalid Input ")
} else {
//put into user session based pipeline
AllInMessage <- in
}

AllInMessage <- in

openID := in.header.FromUserName
if openID == "" {
log.Println("nothing")
}

//dummy reply
reply, _ := BuildTextMsg(openID, "澳")
w.Header().Set("Content-Type", "text/xml; charset=utf-8")
fmt.Fprint(w, reply)

//time.Sleep(5 * time.Second)
v := reflect.ValueOf(answerWechatPost)
log.Printf("Current Pointer: %d", v.Pointer())
//debug.PrintStack()

//load session into memory
// session := startSession(openID, in, w, r) //who , input what?
// session.ProcessInput()
// //put session back to disk
// session.Save()
}

// func (session) ProcessInput(w, r) {

Chargement…
Annuler
Enregistrer