Skip to content

Instantly share code, notes, and snippets.

@abepark01
Created August 4, 2021 19:45
Show Gist options
  • Save abepark01/e06978dd4393089556eb30121c54e3e8 to your computer and use it in GitHub Desktop.
Save abepark01/e06978dd4393089556eb30121c54e3e8 to your computer and use it in GitHub Desktop.
Pubnub Create Channel
pubnub = Pubnub.new(subscribe_key: ENV['PUBNUB_SUBSCRIBE_KEY'], publish_key: ENV['PUBNUB_PUB_KEY'], uuid: ENV['PUBNUB_SITE_UUID'])
pubnub.set_channel_metadata(channel: 'sparkxyz', metadata: { name: 'sparkxyz', description: 'Spark XYZ Chat', custom: { workspace: 'sparkxyz' } }, include: { custom: true }, http_sync: true) do |envelope|
puts envelope.inspect
end
<<-DOC
#<Pubnub::ErrorEnvelope:0x00007fa4ebbbcfa0 @id="bf39553e-8f30-411f-9700-b83bed104d63", @event=:set_channel_metadata, @event_options={:channel=>"sparkxyz", :metadata=>{:name=>"sparkxyz", :description=>"Spark XYZ Chat", :custom=>{:workspace=>"sparkxyz"}}, :include=>{:custom=>true}, :http_sync=>true, :callback=>#<Proc:0x00007fa4f45b2200 (pry):8>}, @status={:code=>408, :operation=>:set_channel_metadata, :client_request=>#<URI::HTTP http://ps.pndsn.com/v2/objects/sub-c-fd0dbd48-dd33-11eb-8c90-a639cde32e15/channels/sparkxyz?include=1&pnsdk=PubNub-Ruby%2F4.6.2&uuid=7b046cc45ba6fce276e542a88a4715ea170be9221f27910098f8565aea4dc1cae4de0cdeac54821bd5acaf6dc69e8e6fe51657b63fe6ab3a5fa5b2a5233d21be>, :server_response=>#<HTTPClient::ReceiveTimeoutError: execution expired>, :data=>nil, :category=>:timeout, :error=>true, :auto_retried=>false, :config=>{:tls=>false, :uuid=>"7b046cc45ba6fce276e542a88a4715ea170be9221f27910098f8565aea4dc1cae4de0cdeac54821bd5acaf6dc69e8e6fe51657b63fe6ab3a5fa5b2a5233d21be", :auth_key=>nil, :origin=>"ps.pndsn.com"}}, @result=nil, @timetoken=nil>
=> #<Pubnub::ErrorEnvelope:0x00007fa4ebbbcfa0
@event=:set_channel_metadata,
@event_options=
{:channel=>"sparkxyz",
:metadata=>{:name=>"sparkxyz", :description=>"Spark XYZ Chat", :custom=>{:workspace=>"sparkxyz"}},
:include=>{:custom=>true},
:http_sync=>true,
:callback=>#<Proc:0x00007fa4f45b2200 (pry):8>},
@id="bf39553e-8f30-411f-9700-b83bed104d63",
@result=nil,
@status=
{:code=>408,
:operation=>:set_channel_metadata,
:client_request=>
#<URI::HTTP http://ps.pndsn.com/v2/objects/sub-c-fd0dbd48-dd33-11eb-8c90-a639cde32e15/channels/sparkxyz?include=1&pnsdk=PubNub-Ruby%2F4.6.2&uuid=7b046cc45ba6fce276e542a88a4715ea170be9221f27910098f8565aea4dc1cae4de0cdeac54821bd5acaf6dc69e8e6fe51657b63fe6ab3a5fa5b2a5233d21be>,
:server_response=>#<HTTPClient::ReceiveTimeoutError: execution expired>,
:data=>nil,
:category=>:timeout,
:error=>true,
:auto_retried=>false,
:config=>
{:tls=>false,
:uuid=>
"7b046cc45ba6fce276e542a88a4715ea170be9221f27910098f8565aea4dc1cae4de0cdeac54821bd5acaf6dc69e8e6fe51657b63fe6ab3a5fa5b2a5233d21be",
:auth_key=>nil,
:origin=>"ps.pndsn.com"}},
@timetoken=nil>
DOC
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment