I am writing an app for Corona SDK (Using LuaSocket) to be able to subscribe and post messages to the example chat server that runs in socket.io (using gevent-websocket 0.9).
I have checked that chat.js on the server interacts with ther server like this:
To subscribe to a room:
socket.subscribe('room-2000')
Or interacting with the chat room:
socket.send({room: 'room-2000', action: 'start', name: 'John'})
socket.send({room: 'room-2000', action: 'message', message: 'hi there!)});
etc..
Full js client script.
But I don't find a way to make an app for Corona SDK to interact with a channel. I managed to connect to the server with:
socket.connect( my_ip, my_port)
But cannot find a way to subscribe or post/receive messages, can someone give me a clue? Will be highly appreciate it.
AFAIK, you need to do a WebSocket handshake. Read the WebSocket specifiation.
Otherwise, I can recommend you this Publish/Subscribe library for CoronaSDK/Nodejs
https://github.com/Overtorment/NoobHub
Related
I want to query the presence of users in a Slack workspace.
Using the old (classic) app, I can do it using presence_query via Slack RTM.
However, RTM requires depracted bot scopes (and the old classic app).
Can I use (and how) presence_query with the new slack app (I'm using python)?
This is my current implementation (using the old classic app):
from slack_sdk.rtm_v2 import RTMClient
rtm_client = RTMClient(token='SLACK_BOT_TOKEN')
#rtm_client.on("presence_change")
def receive_presence_changes(client:RTMClient, event:dict):
print(event)
rtm_client.connect()
rtm_client.send(
payload={
"type" : "presence_query",
'ids' : ids_list,
}
)
No, there are currently no ways to subscribe to presence-oriented events on the Events API or via Socket Mode. The legacy RTM API is the only avenue still available.
I'm exploring possibilities of creating a Bot for iMessages. I went through the "Messages SDK" provided by Apple for iMessage extensions and didn't find any leads.
Android has Telephony(https://developer.android.com/reference/android/provider/Telephony) which I could use as a starting point. But I couldn't find anything similar on iOS.
If anyone knows how I could achieve this, it would be of great help.
You might want to check out Jared, an open-source iMessage chatbot which reads from the message database.
https://github.com/ZekeSnider/Jared
You could check out https://sendblue.co
Here is their documentation: https://docs.sendblue.co
I assume you can send and receive iMessages by simply hitting their endpoint with a post request, like so:
const url = `https://api.sendblue.co/api/send-message` ;
axios.post(url, {
number: '+19998887777',
content: 'Hello world!',
statusCallback: 'https://example.com/message-status/1234abcd',
},
headers: {
"sb-api-key-id": << apiKey >> ,
"sb-api-secret-key": << apiSecret >>
},
}).then(response => {
console.log(response.data);
}).catch(error => {
console.error(error);
});
You can receive iMessages by registering a webhook with them.
Cheers
iMessages is a closed platform, I don't think I have that possibility.
you can check
https://developer.apple.com/business-chat/
Business Chat
is a powerful new way for organizations to connect with customers directly from within Messages. Using Business Chat, your customers can get answers to questions, resolve issues and complete transactions on their iPhone, iPad, Mac and Apple Watch. Customers can find your business and start conversations from Safari, Maps, Search and Siri.
I have an idea! You could just add a phone number or an email to the chat that is connected to a bot script which would send messages directly from that phone number/email. I think that would work.
I have been trying to make a web app that has a certain feature like uber where users can see other users on a map. I read about pubNub (https://www.pubnub.com/) and I saw they have a tutorial that allows you to track movements on a map https://www.pubnub.com/tutorials/javascript/mapping-javascript-tracking/.
They also provide a tool called presence (https://www.pubnub.com/products/presence/) which allows you to see if users have joined your web session or not. I would like to, with presence, to show on a map if people have joined the session or left the session. If they are on the map, I would like the movements to be updated as well.
I am just wondering if someone has used pubNub before to achieve something similar and if so how to go about it?
Clone Uber with PubNub and EON Maps
https://github.com/pubnub/pubnUber - GitHub Repository
Today we're going to use Phonegap and PubNub to create a simple taxi hailing app. What we'll walk through today is the same technology stack used by Uber, Gett, and other taxi hailing apps. They all work in a similar fashion.
Getting started
Install phonegap on the CLI.
Clone this repository locally.
The repo contains two directories /rider and /driver. We're going to start with /driver.
Set Up PubNub
First, we need to set up PubNub. the PUBNUB variables comes for free from the EON library. The publish_key and subscribe_key settings come from your PubNub account.
var channel = "pubnub-taxi-app";
var pubnub = PUBNUB.init({
publish_key: 'demo',
subscribe_key: 'demo'
});
The pubnub plugs the same pubnub variable we configured in the first step into EON. This lets us use our own PubNub keys within EON.
Our Mapbox configuration is set and we're ready to send some
Publish messages to the channel
Define our PubNub channel.
Subscribe.
pubnub.subscribe({
channel: channel,
message: function(message,env,channel){
if(message == 'hail') {
var pickup = confirm("Someone requested a ride!", "Accept");
if(pickup) {
pubnub.publish({
channel: channel,
message: 'pickup'
});
}
}
}
});
And here is the hail() function.
var hail = function(argument) {
pubnub.publish({
channel: channel,
message: 'hail'
});
alert('Waiting for driver...');
};
I am using the Twilio API and can successfully make outgoing calls to a phone number, but when I try to enter another username to connect to, nothing happens. I have two emulators running (one with the Android quickstart client, with which I can make outgoing calls to another user. I can make calls from the Android client to the iOS client using usernames and it works fine, but when I try to do the same from the iOS client to the Android client, nothing happens. I don't get a crash or anything, I just get the initial sound that it tries to start, then the disconnect sound. Here is my code:
- (IBAction)dialButtonPressed:(id)sender {
[self.dialField resignFirstResponder];
NSDictionary *params = #{#"To": self.dialField.text};
_connection = [_phone connect:params delegate:nil];
}
I have searched everywhere I can think of online, but every reference seems to talk only about calls with a phone number. The Twilio API for Android handles this easily, but I cannot figure it out for iOS. Any suggestions would be greatly appreciated.
Thanks in advance!!
Much thanks to Zack from Twilio who finally noticed that we just needed to add client: before the username when trying to call a user rather than a phone number (When using the Heroku App for the server setup as instructed in the Quickstart tutorial). Not sure why this is not built into the iOS instructions, but it is to the Android version. I'm just glad to have something that works.
I just have to dial client: then the username right into the dial field and it works. Now I can make any desired programming changes.
Thanks
Context:
I am developing a Ruby On Rails application and I started using React.js to manage my javascript components.
My application provides a facebook-like chat: several chats are displayed at the bottom of the page.
Problem
I have a ChatList component that renders the chats. A chat is made of its messages and its form. When this form is submitted, an AJAX call is made to the server to POST the message and the message is added to the current chat.
this.setState({messages: this.state.messages.concat([newMessage])});
The server then broadcast Javascript code to the receiver.
This is where I'm stuck. How can I add the message to the correct chat? How can I select my React.js component and change its 'props'?
When I was not using react, I used to broadcast this code to the other user:
$("#chat-<%= chat.id %>").append("<%= message.content" %>);
I guess I have to find a way to select the React component (the chat instance) and change its property "messages". How?
Thank you for your help! :)
EDIT: I'm going to add more information, just in case:
My ChatList is a global variable that takes an array of Chats.
Each Chat takes an array of Message and a form.
When I submit the form of a chat, it adds the message to the Chat (locally and it also posts the new message to the server). When the server receives the POST event, it can render javascript code to the other user.
This code should add the message to the correct Chat for the correct user. There are two pieces missing:
I don't know how I can "select" the Chat.
I don't know how I can add a message to the "messages" array of this Chat.
You'll want to have your chat component listen to a WebSocket event for a new message and then call setState when a message is received.
The standard approach with Chatrooms is to use "channels" that each chat room subscribes to. That way it only hears about incoming messages from the conversation it cares about.
Check out Socket.io and its example on making a chat application. Even if you don't use Socket.io the example will be illustrative.
The solution, in my Chat class:
componentDidMount: function(){
this.props.privateChannel.bind('message.new', this.receiveMessage);
},
receiveMessage: function(message) {
if(message.user.id == this.props.recipient.id){
this.setState({messages: this.state.messages.concat([message])});
this.startBlink();
}
},