本文整理汇总了Golang中github.com/pubnub/go/pubnubMessaging.PubnubInit函数的典型用法代码示例。如果您正苦于以下问题:Golang PubnubInit函数的具体用法?Golang PubnubInit怎么用?Golang PubnubInit使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了PubnubInit函数的18个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: 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 pubnubMessaging 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
pubnubInstance := pubnubMessaging.PubnubInit("demo", "demo", "", cipherKey, false, "")
message := "Test Message "
channel := "testChannel"
messagesSent := PublishMessages(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 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:rajat010,项目名称:go,代码行数:29,代码来源:pubnubDetailedHistory_test.go
示例2: TestLargeMessage
// TestLargeMessage tests the client by publshing a large message
// An error "message to large" should be returned from the server
func TestLargeMessage(t *testing.T) {
pubnubInstance := pubnubMessaging.PubnubInit("demo", "demo", "", "", false, "")
channel := "testChannel"
message := "This is a large message test which will return an error message. This is a large message test which will return an error message. This is a large message test which will return an error message. This is a large message test which will return an error message. This is a large message test which will return an error message. This is a large message test which will return an error message. This is a large message test which will return an error message. This is a large message test which will return an error message. This is a large message test which will return an error message. This is a large message test which will return an error message. This is a large message test which will return an error message. This is a large message test which will return an error message. This is a large message test which will return an error message. This is a large message test which will return an error message. This is a large message test which will return an error message. This is a large message test which will return an error message. This is a large message test which will return an error message. This is a large message test which will return an error message. This is a large message test which will return an error message. This is a large message test which will return an error message. This is a large message test which will return an error message. This is a large message test which will return an error message. This is a large message test which will return an error message. This is a large message test which will return an error message. This is a large message test which will return an error message. This is a large message test which will return an error message. This is a large message test which will return an error message. This is a large message test which will return an error message. This is a large message test which will return an error message. This is a large message test which will return an error message. This is a large message test which will return an error message. This is a large message test which will return an error message. "
returnChannel := make(chan []byte)
errorChannel := make(chan []byte)
responseChannel := make(chan string)
waitChannel := make(chan string)
go pubnubInstance.Publish(channel, message, returnChannel, errorChannel)
go ParseLargeResponse("Message Too Large", errorChannel, responseChannel)
go WaitForCompletion(responseChannel, waitChannel)
ParseWaitResponse(waitChannel, t, "MessageTooLarge")
}
开发者ID:rajat010,项目名称:go,代码行数:16,代码来源:pubnubPublish_test.go
示例3: TestServerTime
// TestServerTime calls the GetTime method of the pubnubMessaging to test the time
func TestServerTime(t *testing.T) {
pubnubInstance := pubnubMessaging.PubnubInit("demo", "demo", "", "", false, "")
returnTimeChannel := make(chan []byte)
errorChannel := make(chan []byte)
responseChannel := make(chan string)
waitChannel := make(chan string)
go pubnubInstance.GetTime(returnTimeChannel, errorChannel)
go ParseTimeResponse(returnTimeChannel, responseChannel)
go ParseErrorResponse(errorChannel, responseChannel)
go WaitForCompletion(responseChannel, waitChannel)
ParseWaitResponse(waitChannel, t, "Time")
}
开发者ID:rajat010,项目名称:go,代码行数:15,代码来源:pubnubTime_test.go
示例4: DetailedHistoryParamsFor10Messages
// 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 pubnubMessaging package to fetch last 10 messages with time parameters
// between which the messages were sent. These received message is compared to the messages sent and
// if all match test is successful.
func DetailedHistoryParamsFor10Messages(t *testing.T, cipherKey string, secretKey string, testName string) {
numberOfMessages := 5
pubnubInstance := pubnubMessaging.PubnubInit("demo", "demo", secretKey, cipherKey, false, "")
message := "Test Message "
channel := "testChannel"
startTime := GetServerTime(pubnubInstance, t, testName)
startMessagesFrom := 0
messagesSent := PublishMessages(pubnubInstance, channel, t, startMessagesFrom, numberOfMessages, message)
midTime := GetServerTime(pubnubInstance, t, testName)
startMessagesFrom = 5
messagesSent2 := PublishMessages(pubnubInstance, channel, t, startMessagesFrom, numberOfMessages, message)
endTime := GetServerTime(pubnubInstance, t, testName)
startMessagesFrom = 0
if messagesSent {
returnHistoryChannel := make(chan []byte)
responseChannel := make(chan string)
errorChannel := make(chan []byte)
waitChannel := make(chan string)
go pubnubInstance.History(channel, numberOfMessages, startTime, midTime, 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.")
}
startMessagesFrom = 5
if messagesSent2 {
returnHistoryChannel2 := make(chan []byte)
errorChannel2 := make(chan []byte)
responseChannel2 := make(chan string)
waitChannel2 := make(chan string)
go pubnubInstance.History(channel, numberOfMessages, midTime, endTime, false, returnHistoryChannel2, errorChannel2)
go ParseHistoryResponseForMultipleMessages(returnHistoryChannel2, channel, message, testName, startMessagesFrom, numberOfMessages, cipherKey, responseChannel2)
go ParseErrorResponse(errorChannel2, responseChannel2)
go WaitForCompletion(responseChannel2, waitChannel2)
ParseWaitResponse(waitChannel2, t, testName)
} else {
t.Error("Test '" + testName + "': failed.")
}
}
开发者ID:rajat010,项目名称:go,代码行数:53,代码来源:pubnubDetailedHistory_test.go
示例5: TestSubscriptionConnectStatus
// TestSubscriptionConnectStatus sends out a subscribe request to a pubnub channel
// and validates the response for the connect status.
func TestSubscriptionConnectStatus(t *testing.T) {
pubnubInstance := pubnubMessaging.PubnubInit("demo", "demo", "", "", false, "")
channel := "testChannel"
returnSubscribeChannel := make(chan []byte)
errorChannel := make(chan []byte)
responseChannel := make(chan string)
waitChannel := make(chan string)
go pubnubInstance.Subscribe(channel, "", returnSubscribeChannel, false, errorChannel)
go ParseSubscribeResponse(pubnubInstance, returnSubscribeChannel, t, channel, "", "SubscriptionConnectStatus", "", responseChannel)
go ParseErrorResponse(errorChannel, responseChannel)
go WaitForCompletion(responseChannel, waitChannel)
ParseWaitResponse(waitChannel, t, "SubscriptionConnectStatus")
}
开发者ID:rajat010,项目名称:go,代码行数:18,代码来源:pubnubSubscribe_test.go
示例6: HereNow
// HereNow is a common method used by the tests TestHereNow, HereNowWithCipher, CustomUuid
// It subscribes to a pubnub channel and then
// makes a call to the herenow method of the pubnub api.
func HereNow(t *testing.T, cipherKey string, customUuid string, testName string) {
pubnubInstance := pubnubMessaging.PubnubInit("demo", "demo", "", cipherKey, false, customUuid)
channel := "testChannel"
returnSubscribeChannel := make(chan []byte)
errorChannel := make(chan []byte)
responseChannel := make(chan string)
waitChannel := make(chan string)
go pubnubInstance.Subscribe(channel, "", returnSubscribeChannel, false, errorChannel)
go ParseSubscribeResponseForPresence(pubnubInstance, customUuid, returnSubscribeChannel, channel, testName, responseChannel)
go ParseErrorResponse(errorChannel, responseChannel)
go WaitForCompletion(responseChannel, waitChannel)
ParseWaitResponse(waitChannel, t, testName)
}
开发者ID:rajat010,项目名称:go,代码行数:19,代码来源:pubnubPresence_test.go
示例7: TestEncryptedDetailedHistory
// TestEncryptedDetailedHistory publish's an encrypted message to a pubnub channel and when the
// sent response is received, calls the history method of the pubnubMessaging package to fetch
// 1 message. This received message is compared to the message sent and if both match test is successful.
func TestEncryptedDetailedHistory(t *testing.T) {
pubnubInstance := pubnubMessaging.PubnubInit("demo", "demo", "", "enigma", false, "")
channel := "testChannel"
message := "Test Message"
returnPublishChannel := make(chan []byte)
errorChannel := make(chan []byte)
responseChannel := make(chan string)
waitChannel := make(chan string)
go pubnubInstance.Publish(channel, message, returnPublishChannel, errorChannel)
go ParseResponse(returnPublishChannel, pubnubInstance, channel, message, "EncryptedDetailedHistory", 1, responseChannel)
go ParseErrorResponse(errorChannel, responseChannel)
go WaitForCompletion(responseChannel, waitChannel)
ParseWaitResponse(waitChannel, t, "EncryptedDetailedHistory")
}
开发者ID:rajat010,项目名称:go,代码行数:19,代码来源:pubnubDetailedHistory_test.go
示例8: TestSuccessCodeAndInfoWithEncryption
// TestSuccessCodeAndInfoWithEncryption sends out an encrypted
// message to the pubnub channel
// The response is parsed and should match the 'sent' status.
// _publishSuccessMessage is defined in the common.go file
func TestSuccessCodeAndInfoWithEncryption(t *testing.T) {
pubnubInstance := pubnubMessaging.PubnubInit("demo", "demo", "", "enigma", 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 ParsePublishResponse(returnChannel, channel, _publishSuccessMessage, "SuccessCodeAndInfoWithEncryption", responseChannel)
go ParseErrorResponse(errorChannel, responseChannel)
go WaitForCompletion(responseChannel, waitChannel)
ParseWaitResponse(waitChannel, t, "SuccessCodeAndInfoWithEncryption")
time.Sleep(2 * time.Second)
}
开发者ID:rajat010,项目名称:go,代码行数:21,代码来源:pubnubPublish_test.go
示例9: TestPresence
// TestPresence subscribes to the presence notifications on a pubnub channel and
// then subscribes to a pubnub channel. The test waits till we get a response from
// the subscribe call. The method that parses the presence response sets the global
// variable _endPresenceTestAsSuccess to true if the presence contains a join info
// on the channel and _endPresenceTestAsFailure is otherwise.
func TestPresence(t *testing.T) {
customUuid := "customuuid"
testName := "Presence"
pubnubInstance := pubnubMessaging.PubnubInit("demo", "demo", "", "", false, customUuid)
channel := "testForPresenceChannel"
returnPresenceChannel := make(chan []byte)
errorChannel := make(chan []byte)
responseChannel := make(chan string)
waitChannel := make(chan string)
go pubnubInstance.Subscribe(channel, "", returnPresenceChannel, true, errorChannel)
go ParseSubscribeResponseForPresence(pubnubInstance, customUuid, returnPresenceChannel, channel, testName, responseChannel)
go ParseResponseDummy(errorChannel)
go WaitForCompletion(responseChannel, waitChannel)
ParseWaitResponse(waitChannel, t, testName)
}
开发者ID:rajat010,项目名称:go,代码行数:22,代码来源:pubnubPresence_test.go
示例10: TestMultiSubscriptionConnectStatus
// TestMultiSubscriptionConnectStatus send out a pubnub multi channel subscribe request and
// parses the response for multiple connection status.
func TestMultiSubscriptionConnectStatus(t *testing.T) {
pubnubInstance := pubnubMessaging.PubnubInit("demo", "demo", "", "", false, "")
testName := "TestMultiSubscriptionConnectStatus"
channels := "testChannel1,testChannel2"
returnSubscribeChannel := make(chan []byte)
errorChannel := make(chan []byte)
responseChannel := make(chan string)
waitChannel := make(chan string)
go pubnubInstance.Subscribe(channels, "", returnSubscribeChannel, false, errorChannel)
go ParseSubscribeResponseForMultipleChannels(returnSubscribeChannel, channels, testName, responseChannel)
go ParseErrorResponse(errorChannel, responseChannel)
go WaitForCompletion(responseChannel, waitChannel)
ParseWaitResponse(waitChannel, t, testName)
}
开发者ID:rajat010,项目名称:go,代码行数:19,代码来源:pubnubSubscribe_test.go
示例11: TestUnsubscribeNotSubscribed
// TestUnsubscribeNotSubscribed will try to unsubscribe a non subscribed pubnub channel.
// The response should contain 'not subscribed'
func TestUnsubscribeNotSubscribed(t *testing.T) {
pubnubInstance := pubnubMessaging.PubnubInit("demo", "demo", "", "", false, "")
currentTime := time.Now()
channel := "testChannel" + currentTime.Format("20060102150405")
returnUnsubscribeChannel := make(chan []byte)
errorChannel := make(chan []byte)
responseChannel := make(chan string)
waitChannel := make(chan string)
go pubnubInstance.Unsubscribe(channel, returnUnsubscribeChannel, errorChannel)
go ParseUnsubscribeResponse(returnUnsubscribeChannel, channel, "not subscribed", responseChannel)
go ParseErrorResponse(errorChannel, responseChannel)
go WaitForCompletion(responseChannel, waitChannel)
ParseWaitResponse(waitChannel, t, "UnsubscribeNotSubscribed")
}
开发者ID:rajat010,项目名称:go,代码行数:19,代码来源:pubnubUnsubscribe_test.go
示例12: SendMultipleResponse
// SendMultipleResponse is the common implementation for TestMultipleResponsed and
// TestMultipleResponseEncrypted
func SendMultipleResponse(t *testing.T, encrypted bool) {
cipher := ""
testName := "TestMultipleResponse"
if encrypted {
cipher = "enigma"
testName = "TestMultipleResponseEncrypted"
}
pubnubInstance := pubnubMessaging.PubnubInit("demo", "demo", "", cipher, false, "")
pubnubChannel := "testChannel"
returnTimeChannel := make(chan []byte)
errorChannelTime := make(chan []byte)
go pubnubInstance.GetTime(returnTimeChannel, errorChannelTime)
retTime, errTime := ParseTimeFromServer(returnTimeChannel, errorChannelTime)
if errTime == nil {
message1 := "message1"
message2 := "message2"
returnPublishChannel := make(chan []byte)
errorChannelPub := make(chan []byte)
go pubnubInstance.Publish(pubnubChannel, message1, returnPublishChannel, errorChannelPub)
b1, _ := ParsePublishResponseFromServer(returnPublishChannel, errorChannelPub)
returnPublishChannel2 := make(chan []byte)
errorChannelPub2 := make(chan []byte)
go pubnubInstance.Publish(pubnubChannel, message2, returnPublishChannel2, errorChannelPub2)
b2, _ := ParsePublishResponseFromServer(returnPublishChannel2, errorChannelPub2)
if b1 && b2 {
returnSubscribeChannel := make(chan []byte)
errorChannelSub := make(chan []byte)
responseChannelSub := make(chan string)
waitChannelSub := make(chan string)
go pubnubInstance.Subscribe(pubnubChannel, retTime, returnSubscribeChannel, false, errorChannelSub)
go ParseSubscribeMultiResponse(pubnubChannel, returnSubscribeChannel, message1, message2, cipher, testName, responseChannelSub)
go ParseErrorResponse(errorChannelSub, responseChannelSub)
go WaitForCompletion(responseChannelSub, waitChannelSub)
ParseWaitResponse(waitChannelSub, t, testName)
}
}
}
开发者ID:rajat010,项目名称:go,代码行数:47,代码来源:pubnubSubscribe_test.go
示例13: TestNullMessage
// TestNullMessage sends out a null message to a pubnub channel. The response should
// be an "Invalid Message".
func TestNullMessage(t *testing.T) {
pubnubInstance := pubnubMessaging.PubnubInit("demo", "demo", "", "", 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 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:rajat010,项目名称:go,代码行数:20,代码来源:pubnubPublish_test.go
示例14: TestSuccessCodeAndInfoForComplexMessage2
// TestSuccessCodeAndInfoForComplexMessage2 sends out a 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 TestSuccessCodeAndInfoForComplexMessage2(t *testing.T) {
pubnubInstance := pubnubMessaging.PubnubInit("demo", "demo", "", "", 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 ParsePublishResponse(returnChannel, channel, _publishSuccessMessage, "SuccessCodeAndInfoForComplexMessage2", responseChannel)
go ParseErrorResponse(errorChannel, responseChannel)
go WaitForCompletion(responseChannel, waitChannel)
ParseWaitResponse(waitChannel, t, "SuccessCodeAndInfoForComplexMessage2")
time.Sleep(2 * time.Second)
}
开发者ID:rajat010,项目名称:go,代码行数:22,代码来源:pubnubPublish_test.go
示例15: 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) {
pubnubInstance := pubnubMessaging.PubnubInit("demo", "demo", "", "", 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 ParsePublishResponse(returnChannel, channel, _publishSuccessMessage, "SuccessCodeAndInfoForComplexMessage", responseChannel)
go ParseErrorResponse(errorChannel, responseChannel)
go WaitForCompletion(responseChannel, waitChannel)
ParseWaitResponse(waitChannel, t, "SuccessCodeAndInfoForComplexMessage")
time.Sleep(2 * time.Second)
}
开发者ID:rajat010,项目名称:go,代码行数:25,代码来源:pubnubPublish_test.go
示例16: ResumeOnReconnect
// ResumeOnReconnect contains the actual impementation of both TestResumeOnReconnectFalse and TestResumeOnReconnectTrue
// the parameter b determines of resume on reconnect setting is true or false.
func ResumeOnReconnect(t *testing.T, b bool) {
testName := "ResumeOnReconnectFalse"
if b {
pubnubMessaging.SetResumeOnReconnect(true)
testName = "ResumeOnReconnectTrue"
} else {
pubnubMessaging.SetResumeOnReconnect(false)
}
pubnubChannel := "testChannel"
pubnubInstance := pubnubMessaging.PubnubInit("demo", "demo", "", "", false, "")
returnSubscribeChannel := make(chan []byte)
errorChannelSub := make(chan []byte)
responseChannelSub := make(chan string)
waitChannelSub := make(chan string)
pubnubMessaging.SetSubscribeTimeout(12)
go pubnubInstance.Subscribe(pubnubChannel, "", returnSubscribeChannel, false, errorChannelSub)
go ParseSubscribeForTimetoken(pubnubInstance, pubnubChannel, returnSubscribeChannel, errorChannelSub, testName, responseChannelSub)
go WaitForCompletion(responseChannelSub, waitChannelSub)
ParseWaitResponse(waitChannelSub, t, testName)
pubnubMessaging.SetSubscribeTimeout(310)
}
开发者ID:rajat010,项目名称:go,代码行数:25,代码来源:pubnubSubscribe_test.go
示例17: SendMultiplexingRequest
// SendMultiplexingRequest is the common method to test TestMultiplexing,
// TestMultiplexingSSL, TestEncryptedMultiplexing, TestEncryptedMultiplexingWithSSL.
//
// It subscribes to 2 channels in the same request and then calls the ParseSubscribeMultiplexedResponse
// for further processing.
//
// Parameters:
// t: *testing.T instance.
// testName: testname for display.
// ssl: ssl setting.
// encrypted: encryption setting.
func SendMultiplexingRequest(t *testing.T, testName string, ssl bool, encrypted bool) {
cipher := ""
if encrypted {
cipher = "enigma"
}
message1 := "message1"
message2 := "message2"
pubnubChannel1 := "testChannel1"
pubnubChannel2 := "testChannel2"
pubnubChannel := pubnubChannel1 + "," + pubnubChannel2
pubnubInstance := pubnubMessaging.PubnubInit("demo", "demo", "", cipher, ssl, "")
returnSubscribeChannel := make(chan []byte)
errorChannelSub := make(chan []byte)
responseChannelSub := make(chan string)
waitChannelSub := make(chan string)
go pubnubInstance.Subscribe(pubnubChannel, "", returnSubscribeChannel, false, errorChannelSub)
go ParseSubscribeMultiplexedResponse(pubnubInstance, returnSubscribeChannel, message1, message2, pubnubChannel1, pubnubChannel2, testName, responseChannelSub)
go ParseErrorResponse(errorChannelSub, responseChannelSub)
go WaitForCompletion(responseChannelSub, waitChannelSub)
ParseWaitResponse(waitChannelSub, t, testName)
}
开发者ID:rajat010,项目名称:go,代码行数:35,代码来源:pubnubSubscribe_test.go
示例18: Init
// Init asks the user the basic settings to initialize to the pubnub struct.
// Settings include the pubnub channel(s) to connect to.
// Ssl settings
// Cipher key
// Secret Key
// Custom Uuid
// Proxy details
//
// The method returns false if the channel name is not provided.
//
// returns: a bool, true if the user completed the initail settings.
func Init() (b bool) {
fmt.Println("PubNub Api for go;", pubnubMessaging.VersionInfo())
fmt.Println("Please enter the channel name(s). Enter multiple channels separated by comma without spaces.")
reader := bufio.NewReader(os.Stdin)
line, _, err := reader.ReadLine()
if err != nil {
fmt.Println(err)
} else {
_connectChannels = string(line)
if strings.TrimSpace(_connectChannels) != "" {
fmt.Println("Channel: ", _connectChannels)
fmt.Println("Enable SSL? Enter y for Yes, n for No.")
var enableSsl string
fmt.Scanln(&enableSsl)
if enableSsl == "y" || enableSsl == "Y" {
_ssl = true
fmt.Println("SSL enabled")
} else {
_ssl = false
fmt.Println("SSL disabled")
}
fmt.Println("Please enter a CIPHER key, leave blank if you don't want to use this.")
fmt.Scanln(&_cipher)
fmt.Println("Cipher: ", _cipher)
fmt.Println("Please enter a Custom UUID, leave blank for default.")
fmt.Scanln(&_uuid)
fmt.Println("UUID: ", _uuid)
fmt.Println("Display error messages? Enter y for Yes, n for No. Default is Yes")
var enableErrorMessages = "y"
fmt.Scanln(&enableErrorMessages)
if enableErrorMessages == "y" || enableErrorMessages == "Y" {
_displayError = true
fmt.Println("Error messages will be displayed")
} else {
_displayError = false
fmt.Println("Error messages will not be displayed")
}
fmt.Println("Enable resume on reconnect? Enter y for Yes, n for No. Default is Yes")
var enableResumeOnReconnect = "y"
fmt.Scanln(&enableResumeOnReconnect)
if enableResumeOnReconnect == "y" || enableResumeOnReconnect == "Y" {
pubnubMessaging.SetResumeOnReconnect(true)
fmt.Println("Resume on reconnect enabled")
} else {
pubnubMessaging.SetResumeOnReconnect(false)
fmt.Println("Resume on reconnect disabled")
}
fmt.Println("Set subscribe timeout? Enter numerals.")
var subscribeTimeout = ""
fmt.Scanln(&subscribeTimeout)
val, err := strconv.Atoi(subscribeTimeout)
if err != nil {
fmt.Println("Entered value is invalid. Using default value.")
} else {
pubnubMessaging.SetSubscribeTimeout(int64(val))
}
pubnubMessaging.SetOrigin("pubsub.pubnub.com")
pubInstance := pubnubMessaging.PubnubInit("demo", "demo", "", _cipher, _ssl, _uuid)
_pub = pubInstance
SetupProxy()
return true
} else {
fmt.Println("Channel cannot be empty.")
}
}
return false
}
开发者ID:rajat010,项目名称:go,代码行数:90,代码来源:pubnubExample.go
注:本文中的github.com/pubnub/go/pubnubMessaging.PubnubInit函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论