Okay, so I'm sure with all the HTML/JavaScript masters on here someone will figure this out.
Ive got this app I'm working on. The objective is this...
1) The user opens my app (objective-c/cocoa) and selects their preferred language.
2) My app opens Facebook.com in whatever the users preferred browser is, except changes the document, in the way that all chat messages received are translated to the preferred language...
How might I go by this? Pretty much replacing the received chat message strings with new ones automatically?
If you need access to Facebook chat specifically, they expose an XMPP API that you can work with: http://developers.facebook.com/docs/chat/ . I haven't used it personally, so I'm not sure if it fully satisfies your requirements, but it may be worth a look.
Related
I know not exactly how to ask this appropriately and where. I tried searching around and visited various (paid) solutions, but I would require a simple solution.
For a scientific work of mine I want to track user interactions or basically button clicks on a simple React site like this example I made http://flock-1401.students.fhstp.ac.at/
Assume the user visits the provided link above, then I want to create a log on a server (maybe nodejs self-hosted) where the user's interaction is tracked with a unique session to distinguish them. At most, there will be 150 users active.
I tried to use the following library:
https://github.com/react-ga/react-ga
However, I tend to not use Google Analytics as I don't need all the included stuff there. Maybe something like this https://github.com/greenstick/interactor? But how do I automatically save it then?
Thank you
I want to have a function that when the user write a comment on message board. User can see the message board update right away without refresh the website, like facebook!
I am new to JS and Ajax, and I found some ways to realize it as bellow. Is there any simple method or API to realize it?
I am totally new. Any advise will be helpful.
I use PHP before btw.
1.Ajax
2.ezcomet
3.Pusher
4.Comet
5.ASP.NET SignalR
You would use ajax or websockets(for games or real time apps). I don't know what 2 and 3 are. I think comet is a library. Message boards usually refresh the page because they are slow. I think your talking about a social network.
I have a Ruby on Rails 3 application, and I want to be able to see a list of who is currently online. For example user1, IP address, and country. I then want to be able to open a chat / push messages to this user until they leave my site.
How can I accurately monitor who is currently on the site and instantly remove the user from the list when they leave?
I then can talk to them via faye pub/sub.
How can I accurately monitor who is currently on the site and instantly remove from list when they leave?
Well using HTTP you can not do this "instantly" in a browser. Almost all solutions I see use a heartbeat technique. Every X seconds, a request is sent from the browser (using Ajax), that tells if the user is online. If you haven't heard from the user in x heartbeats, you regard the user as disconnected - even Facebook uses this, it seems. I will recommend you to drop your requirement for instant, unless it's really important.
Another approach is to implement Flash or Silverlight, to make a socket connection to the server. But the demand on the server is high, and if many people is on your site, you will run into trouble with ports and so on.
I think this is not so much related with Ruby on Rails... but this is very hard to implement in HTTP with a scripting language only. The server does not know whether a user has closed the browser or not. The server just sends the requested page data to the user and closes the connection.
You would rather have to integrate Ajax or Flash to make things easier. I have seen some people developing chat programs with Flash, and it seems to work much better than any other Ajax-implemented chat programs.
Chat is very unfavorable in a web browsing context, since the page will be reloaded as the user clicks a link. If you are thinking about building an application that only supports a chat feature, you probably want to look something other than Ruby on Rails. For example, Node.js will be a good one.
I have a online user list which is populated by a SQL query to a database table.
When a new user comes online, how can i make the webpage automatically update?
What code do I need to provide?
Thanks
There are a few ways you could do this, but I'll avoid the most tempting WebSockets HTML5 new-ness and suggest the following:
When a user logs on, record the fact that they are logged on to the database.
From your page, poll a service or web page method that lists online users.
If the list changes, update the part of the page that shows the users.
That's the rough outline of what to do. If you need specifics please say what server-side host and programming language you are using. From the client side, please also mention what JavaScript framework you'd prefer or are open to.
Can someone illustrate how I can get typing status of the other party with JavaScript?
UPDATE
Can someone recommend a one-to-one open source chatting application, preferably written in PHP? I only found open source chatting rooms which are for chatting among all onliners, but I just need a one-to-one chatting.
Here are a list of PHP-based open-source instant messaging software.
Some of those might be relevant for you.
For example, if you had an text area #chat then you could use this code to attach the event:
document.getElementById('chat').addEventListener('keydown', FUNCTION HERE, false);
See http streaming and some ready solutions here: http://ajaxpatterns.org/HTTP_Streaming
this is how google talk does it. And there are ready php or c++ solutions
It was quie a discovery for me!
This is an update to reflect the significant change in the OP's question:
Google Chat and Facebook both use XMPP(jabber) servers, as do most companies I know of that have internal instant messaging.
The nice part about XMPP is that you get all of the "is typing" and other presence-based information without having to roll-your-own in javascript (bear in mind, you will still need to use javascript to pass XMPP requests back to the server, but XMPP has most of the features you'd need already built in).
Check out OpenFire. It's a great XMPP server, totally open source, and they have a web-based version of their Spark client that is pretty nice.
Or you could get a PHP library for XMPP (there are a few). But you'd still need to have the XMPP server running in the background for PHP to work with.
Here's a list of XMPP libraries for PHP from XMPP.org:
Eiffel
JAXL
Lightr
Missus
xmpphp
Or, if you want to keep things mostly browser-side, they also have a list of libraries for javascript:
dojox.xmpp
js.io
JSJaC
strophe.js
xmpp4gwt
xmpp4js
I made a small chat application a while ago, and the only way to do it is to frequently check for new entries in the chat database and fetch anything newer than the last displayed message. At the same time as all that, you can check to see if the user's input is empty. If it is, do nothing. If it isn't, enter a status code into the database beside that user's name. If anyone has that status in the database when you're fetching information about new messages and who is online, you should display the 'user is typing' message. I hope that makes sense...let me know if it isn't.
For User1: If you save the chat message on each key-press to the database, with a status: sent=false and update the last updated date.
For User2: you could pole periodically for the presence of a message where sent=false and use the last updated to update user is typing message. if the lastupdated date is more than a say ten seconds you could remove the message as that person may have stopped typing. This will allow User2 to see User1 typing, stopping and continueing again.
Ideally polling for this information will be part of an existing call to the database to reduce additional overhead.