• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Golang messaging.New函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中github.com/pubnub/go/gae/messaging.New函数的典型用法代码示例。如果您正苦于以下问题:Golang New函数的具体用法?Golang New怎么用?Golang New使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了New函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。

示例1: hereNow

func hereNow(w http.ResponseWriter, r *http.Request) {
	q := r.URL.Query()
	channel := q.Get("ch")
	uuid := q.Get("uuid")
	hereNowShowUUID := q.Get("showUUID")
	hereNowIncludeUserState := q.Get("includeUserState")

	disableUUID := false
	includeUserState := false
	if hereNowShowUUID == "1" {
		disableUUID = true
	}
	if hereNowIncludeUserState == "1" {
		includeUserState = true
	}

	errorChannel := make(chan []byte)
	successChannel := make(chan []byte)

	//c := context.NewContext(r)
	c := createContext(r)
	pubInstance := messaging.New(c, uuid, w, r, publishKey, subscribeKey, secretKey, "", false)
	go pubInstance.HereNow(c, w, r, channel, disableUUID, includeUserState, successChannel, errorChannel)
	handleResult(c, w, r, uuid, successChannel, errorChannel, messaging.GetNonSubscribeTimeout(), "HereNow")
}
开发者ID:pubnub,项目名称:go,代码行数:25,代码来源:main.go


示例2: TestSuccessCodeAndInfo

// TestSuccessCodeAndInfo sends out a message to the pubnub channel
// The response is parsed and should match the 'sent' status.
// _publishSuccessMessage is defined in the common.go file
func TestSuccessCodeAndInfo(t *testing.T) {
	context, err := aetest.NewContext(nil)
	if err != nil {
		t.Fatal(err)
	}
	defer context.Close()
	uuid := ""
	w, req := InitAppEngineContext(t)

	pubnubInstance := messaging.New(context, uuid, w, req, PubKey, SubKey, "", "", false)
	//pubnubInstance := messaging.NewPubnub(PubKey, SubKey, "", "", false, "")
	channel := "testChannel"
	message := "Pubnub API Usage Example"
	returnChannel := make(chan []byte)
	errorChannel := make(chan []byte)
	responseChannel := make(chan string)
	waitChannel := make(chan string)

	//go pubnubInstance.Publish(channel, message, returnChannel, errorChannel)
	go pubnubInstance.Publish(context, w, req, channel, message, returnChannel, errorChannel)
	go ParsePublishResponse(returnChannel, channel, publishSuccessMessage, "SuccessCodeAndInfo", responseChannel)

	go ParseErrorResponse(errorChannel, responseChannel)
	go WaitForCompletion(responseChannel, waitChannel)
	ParseWaitResponse(waitChannel, t, "SuccessCodeAndInfo")
	time.Sleep(2 * time.Second)
}
开发者ID:kiran-mk,项目名称:go,代码行数:30,代码来源:pubnubPublish_test.go


示例3: TestSuccessCodeAndInfoForComplexMessage

// TestSuccessCodeAndInfoForComplexMessage sends out a complex message to the pubnub channel
// The response is parsed and should match the 'sent' status.
// _publishSuccessMessage and customstruct is defined in the common.go file
func TestSuccessCodeAndInfoForComplexMessage(t *testing.T) {
	context, err := aetest.NewContext(nil)
	if err != nil {
		t.Fatal(err)
	}
	defer context.Close()
	uuid := ""
	w, req := InitAppEngineContext(t)

	pubnubInstance := messaging.New(context, uuid, w, req, PubKey, SubKey, "", "", false)

	//pubnubInstance := messaging.NewPubnub(PubKey, SubKey, "", "", false, "", "", false)
	channel := "testChannel"

	customStruct := CustomStruct{
		Foo: "hi!",
		Bar: []int{1, 2, 3, 4, 5},
	}

	returnChannel := make(chan []byte)
	errorChannel := make(chan []byte)
	responseChannel := make(chan string)
	waitChannel := make(chan string)

	//go pubnubInstance.Publish(channel, customStruct, returnChannel, errorChannel)
	go pubnubInstance.Publish(context, w, req, channel, customStruct, returnChannel, errorChannel)
	go ParsePublishResponse(returnChannel, channel, publishSuccessMessage, "SuccessCodeAndInfoForComplexMessage", responseChannel)

	go ParseErrorResponse(errorChannel, responseChannel)
	go WaitForCompletion(responseChannel, waitChannel)
	ParseWaitResponse(waitChannel, t, "SuccessCodeAndInfoForComplexMessage")
	time.Sleep(2 * time.Second)
}
开发者ID:kiran-mk,项目名称:go,代码行数:36,代码来源:pubnubPublish_test.go


示例4: TestNullMessage

// TestNullMessage sends out a null message to a pubnub channel. The response should
// be an "Invalid Message".
func TestNullMessage(t *testing.T) {
	context, err := aetest.NewContext(nil)
	if err != nil {
		t.Fatal(err)
	}
	defer context.Close()
	uuid := ""
	w, req := InitAppEngineContext(t)

	pubnubInstance := messaging.New(context, uuid, w, req, PubKey, SubKey, "", "", false)

	//pubnubInstance := messaging.NewPubnub(PubKey, SubKey, "", "", false, "")
	channel := "testChannel"
	var message interface{}
	message = nil
	returnChannel := make(chan []byte)
	errorChannel := make(chan []byte)
	responseChannel := make(chan string)
	waitChannel := make(chan string)

	//go pubnubInstance.Publish(channel, message, returnChannel, errorChannel)
	go pubnubInstance.Publish(context, w, req, channel, message, returnChannel, errorChannel)
	//go ParsePublishResponse(returnChannel, channel, "Invalid Message", "NullMessage", responseChannel)
	go ParseResponseDummy(returnChannel)
	go ParseErrorResponseForTestSuccess("Invalid Message", errorChannel, responseChannel)
	//go ParseErrorResponse(errorChannel, responseChannel)
	go WaitForCompletion(responseChannel, waitChannel)
	ParseWaitResponse(waitChannel, t, "NullMessage")
}
开发者ID:kiran-mk,项目名称:go,代码行数:31,代码来源:pubnubPublish_test.go


示例5: TestServerTime

// TestServerTime calls the GetTime method of the messaging to test the time
func TestServerTime(t *testing.T) {
	/*context, err := aetest.NewContext(nil)
	if err != nil {
		t.Fatal(err)
	}
	defer context.Close()*/
	inst, err := aetest.NewInstance(&aetest.Options{"", true})
	context := CreateContext(inst)

	if err != nil {
		t.Fatal(err)
	}
	defer inst.Close()

	uuid := ""
	w, req := InitAppEngineContext(t)

	pubnubInstance := messaging.New(context, uuid, w, req, PubKey, SubKey, "", "", false)
	//pubnubInstance := messaging.NewPubnub(PubKey, SubKey, "", "", false, "")

	returnTimeChannel := make(chan []byte)
	errorChannel := make(chan []byte)
	responseChannel := make(chan string)
	waitChannel := make(chan string)

	//go pubnubInstance.GetTime(returnTimeChannel, errorChannel)
	go pubnubInstance.GetTime(context, w, req, returnTimeChannel, errorChannel)
	go ParseTimeResponse(returnTimeChannel, responseChannel)
	go ParseErrorResponse(errorChannel, responseChannel)
	go WaitForCompletion(responseChannel, waitChannel)
	ParseWaitResponse(waitChannel, t, "Time")
}
开发者ID:GleasonK,项目名称:go,代码行数:33,代码来源:pubnubTime_test.go


示例6: grantSubscribe

func grantSubscribe(w http.ResponseWriter, r *http.Request) {
	q := r.URL.Query()
	ch := q.Get("ch")
	read := q.Get("r")
	write := q.Get("w")
	ttl := q.Get("ttl")
	bRead := false
	if read == "1" {
		bRead = true
	}
	bWrite := false
	if write == "1" {
		bWrite = true
	}
	iTTL := 1440
	if ival, err := strconv.Atoi(ttl); err == nil {
		iTTL = ival
	}

	uuid := q.Get("uuid")
	c := appengine.NewContext(r)
	pubInstance := messaging.New(c, uuid, w, r, publishKey, subscribeKey, secretKey, "", false)
	errorChannel := make(chan []byte)
	successChannel := make(chan []byte)
	go pubInstance.GrantSubscribe(c, w, r, ch, bRead, bWrite, iTTL, successChannel, errorChannel)
	handleResult(c, w, r, uuid, successChannel, errorChannel, messaging.GetNonSubscribeTimeout(), "Revoke Subscribe")
}
开发者ID:kiran-mk,项目名称:go,代码行数:27,代码来源:main.go


示例7: getAuthKey

func getAuthKey(w http.ResponseWriter, r *http.Request) {
	q := r.URL.Query()
	uuid := q.Get("uuid")
	c := appengine.NewContext(r)
	pubInstance := messaging.New(c, uuid, w, r, publishKey, subscribeKey, secretKey, "", false)
	sendResponseToChannel(w, "Auth key: "+pubInstance.GetAuthenticationKey(), r, uuid)
}
开发者ID:kiran-mk,项目名称:go,代码行数:7,代码来源:main.go


示例8: revokeSubscribe

func revokeSubscribe(w http.ResponseWriter, r *http.Request) {
	q := r.URL.Query()
	ch := q.Get("ch")
	uuid := q.Get("uuid")
	c := appengine.NewContext(r)
	pubInstance := messaging.New(c, uuid, w, r, publishKey, subscribeKey, secretKey, "", false)
	errorChannel := make(chan []byte)
	successChannel := make(chan []byte)
	go pubInstance.GrantSubscribe(c, w, r, ch, false, false, 0, successChannel, errorChannel)
	handleResult(c, w, r, uuid, successChannel, errorChannel, messaging.GetNonSubscribeTimeout(), "Revoke Subscribe")
}
开发者ID:kiran-mk,项目名称:go,代码行数:11,代码来源:main.go


示例9: setAuthKey

func setAuthKey(w http.ResponseWriter, r *http.Request) {
	q := r.URL.Query()
	authKey := q.Get("authkey")
	uuid := q.Get("uuid")

	//c := context.NewContext(r)
	c := createContext(r)
	pubInstance := messaging.New(c, uuid, w, r, publishKey, subscribeKey, secretKey, "", false)
	pubInstance.SetAuthenticationKey(c, w, r, authKey)
	sendResponseToChannel(w, "Auth key set", r, uuid)
}
开发者ID:pubnub,项目名称:go,代码行数:11,代码来源:main.go


示例10: auditPresence

func auditPresence(w http.ResponseWriter, r *http.Request) {
	q := r.URL.Query()
	ch := q.Get("ch")
	uuid := q.Get("uuid")
	//c := context.NewContext(r)
	c := createContext(r)
	pubInstance := messaging.New(c, uuid, w, r, publishKey, subscribeKey, secretKey, "", false)
	errorChannel := make(chan []byte)
	successChannel := make(chan []byte)
	go pubInstance.AuditPresence(c, w, r, ch, "", successChannel, errorChannel)
	handleResult(c, w, r, uuid, successChannel, errorChannel, messaging.GetNonSubscribeTimeout(), "Audit Presence")
}
开发者ID:pubnub,项目名称:go,代码行数:12,代码来源:main.go


示例11: whereNow

func whereNow(w http.ResponseWriter, r *http.Request) {
	q := r.URL.Query()
	whereNowUUID := q.Get("whereNowUUID")
	uuid := q.Get("uuid")

	errorChannel := make(chan []byte)
	successChannel := make(chan []byte)

	c := appengine.NewContext(r)
	pubInstance := messaging.New(c, uuid, w, r, publishKey, subscribeKey, secretKey, "", false)
	go pubInstance.WhereNow(c, w, r, whereNowUUID, successChannel, errorChannel)
	handleResult(c, w, r, uuid, successChannel, errorChannel, messaging.GetNonSubscribeTimeout(), "WhereNow")
}
开发者ID:kiran-mk,项目名称:go,代码行数:13,代码来源:main.go


示例12: deleteUserState

func deleteUserState(w http.ResponseWriter, r *http.Request) {
	q := r.URL.Query()
	ch := q.Get("ch")
	key := q.Get("k")
	uuid := q.Get("uuid")
	c := appengine.NewContext(r)
	pubInstance := messaging.New(c, uuid, w, r, publishKey, subscribeKey, secretKey, "", false)
	errorChannel := make(chan []byte)
	successChannel := make(chan []byte)

	go pubInstance.SetUserStateKeyVal(c, w, r, ch, key, "", successChannel, errorChannel)
	handleResult(c, w, r, uuid, successChannel, errorChannel, messaging.GetNonSubscribeTimeout(), "Del User State")
}
开发者ID:kiran-mk,项目名称:go,代码行数:13,代码来源:main.go


示例13: DetailedHistoryFor10Messages

// DetailedHistoryFor10Messages is a common method used by both TestDetailedHistoryFor10EncryptedMessages
// and TestDetailedHistoryFor10Messages to publish's 10 messages to a pubnub channel, and after that
// call the history method of the messaging package to fetch last 10 messages. These received
// messages are compared to the messages sent and if all match test is successful.
func DetailedHistoryFor10Messages(t *testing.T, cipherKey string, testName string) {
	numberOfMessages := 10

	startMessagesFrom := 0

	/*context, err := aetest.NewContext(nil)
	    if err != nil {
			t.Fatal(err)
	    }
	    defer context.Close()
	    w := httptest.NewRecorder()
	    req, _ := http.NewRequest("GET", "/", nil)*/
	//context, err := aetest.NewContext(nil)
	//req, _ := http.NewRequest("GET", "/", nil)
	inst, err := aetest.NewInstance(&aetest.Options{"", true})
	context := CreateContext(inst)

	if err != nil {
		t.Fatal(err)
	}
	//defer context.Close()
	defer inst.Close()
	uuid := ""
	w, req := InitAppEngineContext(t)

	//pubnubInstance := messaging.NewPubnub(PubKey, SubKey, SecKey, cipherKey, false, "")
	pubnubInstance := messaging.New(context, uuid, w, req, PubKey, SubKey, SecKey, "", false)

	message := "Test Message "
	r := GenRandom()
	channel := fmt.Sprintf("testChannel_dh_%d", r.Intn(20))

	messagesSent := PublishMessages(context, w, req, pubnubInstance, channel, t, startMessagesFrom, numberOfMessages, message)
	if messagesSent {
		returnHistoryChannel := make(chan []byte)
		errorChannel := make(chan []byte)
		responseChannel := make(chan string)
		waitChannel := make(chan string)

		//go pubnubInstance.History(channel, numberOfMessages, 0, 0, false, returnHistoryChannel, errorChannel)
		go pubnubInstance.History(context, w, req, channel, numberOfMessages, 0, 0, false, returnHistoryChannel, errorChannel)
		go ParseHistoryResponseForMultipleMessages(returnHistoryChannel, channel, message, testName, startMessagesFrom, numberOfMessages, cipherKey, responseChannel)
		go ParseErrorResponse(errorChannel, responseChannel)
		go WaitForCompletion(responseChannel, waitChannel)
		ParseWaitResponse(waitChannel, t, testName)
	} else {
		t.Error("Test '" + testName + "': failed.")
	}
}
开发者ID:GleasonK,项目名称:go,代码行数:53,代码来源:pubnubDetailedHistory_test.go


示例14: detailedHistory

func detailedHistory(w http.ResponseWriter, r *http.Request) {
	q := r.URL.Query()
	ch := q.Get("ch")
	uuid := q.Get("uuid")
	start := q.Get("start")
	var iStart int64
	if strings.TrimSpace(start) != "" {
		bi := big.NewInt(0)
		if _, ok := bi.SetString(start, 10); !ok {
			iStart = 0
		} else {
			iStart = bi.Int64()
		}
	}

	end := q.Get("end")
	var iEnd int64
	if strings.TrimSpace(end) != "" {
		bi := big.NewInt(0)
		if _, ok := bi.SetString(end, 10); !ok {
			iEnd = 0
		} else {
			iEnd = bi.Int64()
		}
	}

	limit := q.Get("limit")
	reverse := q.Get("reverse")

	iLimit := 100
	if ival, err := strconv.Atoi(limit); err == nil {
		iLimit = ival
	}

	bReverse := false
	if reverse == "1" {
		bReverse = true
	}

	//	ctx := context.NewContext(r)
	ctx := createContext(r)

	pubInstance := messaging.New(ctx, uuid, w, r, publishKey, subscribeKey, secretKey, "", false)
	errorChannel := make(chan []byte)
	successChannel := make(chan []byte)

	go pubInstance.History(ctx, w, r, ch, iLimit, iStart, iEnd, bReverse, successChannel, errorChannel)
	handleResult(ctx, w, r, uuid, successChannel, errorChannel, messaging.GetNonSubscribeTimeout(), "Detailed History")
}
开发者ID:pubnub,项目名称:go,代码行数:49,代码来源:main.go


示例15: publish

func publish(w http.ResponseWriter, r *http.Request) {
	q := r.URL.Query()
	message := q.Get("m")
	uuid := q.Get("uuid")
	ch := q.Get("ch")
	fire := q.Get("fire")
	//meta, _ := url.QueryUnescape(q.Get("meta"))
	metaKey := q.Get("metakey")
	metaVal := q.Get("metaval")
	storeInHistory := q.Get("storeInHistory")
	storeInHistoryBool := false
	if storeInHistory == "1" {
		storeInHistoryBool = true
	}

	errorChannel := make(chan []byte)
	successChannel := make(chan []byte)
	meta := make(map[string]string)
	if strings.TrimSpace(metaKey) != "" && strings.TrimSpace(metaVal) != "" {
		meta[metaKey] = metaVal
	} else {
		meta = nil
	}

	//c := context.NewContext(r)
	c := createContext(r)

	/*message1 := make(map[string]string)
	message1["author"] = "user-a"
	message1["status"] = "I am reading about Advanced Channel Groups!"
	message1["timestamp"] = time.Now().String()*/

	pubInstance := messaging.New(c, uuid, w, r, publishKey, subscribeKey, secretKey, "", false)
	//go pubInstance.Publish(c, w, r, "my_channel", message1, successChannel, errorChannel)

	if fire == "1" {
		go pubInstance.Fire(c, w, r, ch, message, false, successChannel, errorChannel)
	} else if meta != nil {
		log.Infof(c, fmt.Sprintf("Meta: %s", meta))
		go pubInstance.PublishExtendedWithMeta(c, w, r, ch, message, meta, storeInHistoryBool, false, successChannel, errorChannel)
	} else if storeInHistoryBool {
		go pubInstance.PublishExtended(c, w, r, ch, message, storeInHistoryBool, false, successChannel, errorChannel)
	} else {
		go pubInstance.Publish(c, w, r, ch, message, successChannel, errorChannel)
	}

	handleResult(c, w, r, uuid, successChannel, errorChannel, messaging.GetNonSubscribeTimeout(), "Publish")
}
开发者ID:pubnub,项目名称:go,代码行数:48,代码来源:main.go


示例16: Publish

// Publish a message using a PubNub client
func Publish(c appengine.Context, w http.ResponseWriter, r *http.Request, ch string, m *PubMessage) {
	uuid := "Server" // Will make custom UUID if empty string
	message, err := json.Marshal(m)
	if err != nil {
		c.Infof("Bad JSON!")
		return
	}

	errorChannel := make(chan []byte)
	successChannel := make(chan []byte)
	timeoutChannel := make(chan bool, 1) // Boolean channel of size 1

	// func New(context, uuid, writer, request, publishKey, subscribeKey, secretKey, cipher, ssl bool) *Pubnub
	pubInstance := messaging.New(c, uuid, w, r, publishKey, subscribeKey, secretKey, "", false)
	go pubInstance.Publish(c, w, r, ch, message, successChannel, errorChannel)

	go func() {
		time.Sleep(1 * time.Second) // Quit after 1 seconds
		timeoutChannel <- true
	}()

	for {
		select {
		case success, ok := <-successChannel:
			if !ok {
				c.Infof("success!OK")
				break
			}
			if string(success) != "[]" {
				c.Infof("success:", string(success))
			}
			return
		case failure, ok := <-errorChannel:
			if !ok {
				c.Infof("fail1:", string("failure"))
				break
			}
			if string(failure) != "[]" {
				c.Infof("fail:", string(failure))
			}
			return
		case <-timeoutChannel:
			c.Infof("timeout:", string("NonSubscribeTimeout"))
			return
		}
	}
}
开发者ID:GleasonK,项目名称:go-publy,代码行数:48,代码来源:util.go


示例17: setUserState

func setUserState(w http.ResponseWriter, r *http.Request) {
	q := r.URL.Query()
	ch := q.Get("ch")
	k := q.Get("k")
	v := q.Get("v")
	uuid := q.Get("uuid")
	//c := context.NewContext(r)
	c := createContext(r)
	pubInstance := messaging.New(c, uuid, w, r, publishKey, subscribeKey, secretKey, "", false)
	errorChannel := make(chan []byte)
	successChannel := make(chan []byte)

	//setUserState

	go pubInstance.SetUserStateKeyVal(c, w, r, ch, k, v, successChannel, errorChannel)
	handleResult(c, w, r, uuid, successChannel, errorChannel, messaging.GetNonSubscribeTimeout(), "Set User State")
}
开发者ID:pubnub,项目名称:go,代码行数:17,代码来源:main.go


示例18: handler

func handler(w http.ResponseWriter, r *http.Request) {
	c := createContext(r)
	log.Infof(c, "IN handler")
	uuid := ""
	pubInstance := messaging.New(c, uuid, w, r, publishKey, subscribeKey, secretKey, "", false)
	if pubInstance == nil {
		log.Errorf(c, "Couldn't create pubnub instance")
		http.Error(w, "Couldn't create pubnub instance", http.StatusInternalServerError)
		return
	}
	nuuid := pubInstance.GetUUID()

	session, err := store.Get(r, "example-session")
	if err != nil {
		log.Errorf(c, "Session store error %s", err.Error())
		http.Error(w, "Session store error", http.StatusInternalServerError)
		return
	}

	//Enhancement: can be kept in memcache
	tok, err := channel.Create(c, nuuid)
	if err != nil {
		http.Error(w, "Couldn't create Channel", http.StatusInternalServerError)
		log.Errorf(c, "channel.Create: %v", err)
		return
	}
	session.Values["token"] = tok

	err1 := mainTemplate.Execute(w, map[string]string{
		"token":        tok,
		"uuid":         nuuid,
		"subscribeKey": subscribeKey,
		"publishKey":   publishKey,
		"secretKey":    secretKey,
	})
	if err1 != nil {
		log.Errorf(c, "mainTemplate: %v", err1)
	}
}
开发者ID:pubnub,项目名称:go,代码行数:39,代码来源:main.go


示例19: TestSuccessCodeAndInfoForComplexMessage2WithSecretAndEncryption

// TestSuccessCodeAndInfoForComplexMessage2WithSecretAndEncryption sends out an
// encypted and secret keyed complex message to the pubnub channel
// The response is parsed and should match the 'sent' status.
// _publishSuccessMessage and InitComplexMessage is defined in the common.go file
func TestSuccessCodeAndInfoForComplexMessage2WithSecretAndEncryption(t *testing.T) {
	/*context, err := aetest.NewContext(nil)
	if err != nil {
		t.Fatal(err)
	}
	defer context.Close()*/
	inst, err := aetest.NewInstance(&aetest.Options{"", true})
	context := CreateContext(inst)

	if err != nil {
		t.Fatal(err)
	}
	defer inst.Close()

	uuid := ""
	w, req := InitAppEngineContext(t)

	pubnubInstance := messaging.New(context, uuid, w, req, PubKey, SubKey, SecKey, "enigma", false)

	//pubnubInstance := messaging.NewPubnub(PubKey, SubKey, "secret", "enigma", false, "", "", false)
	channel := "testChannel"

	customComplexMessage := InitComplexMessage()

	returnChannel := make(chan []byte)
	errorChannel := make(chan []byte)
	responseChannel := make(chan string)
	waitChannel := make(chan string)

	//go pubnubInstance.Publish(channel, customComplexMessage, returnChannel, errorChannel)
	go pubnubInstance.Publish(context, w, req, channel, customComplexMessage, returnChannel, errorChannel)
	go ParsePublishResponse(returnChannel, channel, publishSuccessMessage, "SuccessCodeAndInfoForComplexMessage2WithSecretAndEncryption", responseChannel)

	go ParseErrorResponse(errorChannel, responseChannel)
	go WaitForCompletion(responseChannel, waitChannel)
	ParseWaitResponse(waitChannel, t, "SuccessCodeAndInfoForComplexMessage2WithSecretAndEncryption")
	time.Sleep(2 * time.Second)
}
开发者ID:GleasonK,项目名称:go,代码行数:42,代码来源:pubnubPublish_test.go


示例20: getUserState

func getUserState(w http.ResponseWriter, r *http.Request) {
	/*successChannel := make(chan []byte)
	errorChannel := make(chan []byte)
	c := createContext(r)
	pubInstance := messaging.New(c, "", w, r, publishKey, subscribeKey, secretKey, "", false)

	go pubInstance.ChannelGroupAddChannel(c, w, r, "cg-user-a-friends", "ch-user-a-present", successChannel, errorChannel)

	select {
	case response := <-successChannel:
		log.Infof(c, "success:", string(response))
	case err := <-errorChannel:
		log.Infof(c, "success:", string(err))
	}

	go pubInstance.ChannelGroupAddChannel(c, w, r, "cg-user-a-status-feed", "ch-user-a-present", successChannel, errorChannel)

	select {
	case response := <-successChannel:
		log.Infof(c, "1success:", string(response))
	case err := <-errorChannel:
		log.Infof(c, "1success:", string(err))
	}*/
	q := r.URL.Query()
	ch := q.Get("ch")
	uuid := q.Get("uuid")

	//c := context.NewContext(r)
	c := createContext(r)
	pubInstance := messaging.New(c, uuid, w, r, publishKey, subscribeKey, secretKey, "", false)
	errorChannel := make(chan []byte)
	successChannel := make(chan []byte)

	go pubInstance.GetUserState(c, w, r, ch, successChannel, errorChannel)
	handleResult(c, w, r, uuid, successChannel, errorChannel, messaging.GetNonSubscribeTimeout(), "Get User State")
}
开发者ID:pubnub,项目名称:go,代码行数:36,代码来源:main.go



注:本文中的github.com/pubnub/go/gae/messaging.New函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang messaging.GetNonSubscribeTimeout函数代码示例发布时间:2022-05-28
下一篇:
Golang messaging.GetNonSubscribeTimeout函数代码示例发布时间:2022-05-28
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap