[Mosquitto-users] Mosquitto+Python+MySQL+APNS

2012-09-17 Thread Yun Kong Tech
Hi,

I knew that Facebook used mosquitto in their messenger app on iPhone. and
it worked pretty well. Here is what they say:
http://www.facebook.com/notes/facebook-engineering/building-facebook-messenger/10150259350998920

I am considering using Mosquitto to implement a chat/messaging service for
my iPhone app as well. I am using Python to write the server side api. so i
am wondering is this this the proper way to do that:

1. set up a broker on the server side
2. using iPhone mosquitto client to connect to it
3. then different client can send message with each other (when they are
all online)

this works fine for some persistent signal monitoring system, but for
chatting experience on mobile, there are two challenges:

*Data Persistence*: I need the server to store all the messages in a
database for the record. so when people log in from anther phone or
reinstall the app, they can still check their message history. I am using
MySQL. I guess Facebook messenger also integrated database storage of
messages, otherwise how the system keep track of all the communication.

*APNS* (Apple Push Notification Service): imagine you are NOT using your
phone or playing another game app (i.e.: the chat app is either not
launched or non-active), your friend send you a message, then there should
be a way for the server to notify you. Apple's solution is
APNS.
Again, it's based on the database and another service provider, which i
will build using python.

here are my questions:

1. what's the best practice to connect Mosquitto broker with the MySQL to
make sure: all messages are stored in the database? Ideally, all message
sent to server should be stored in the db *before *they are distributed, to
ensure the data security.

2. when the server know one client is not active/connected, the server
should call the APNS service to send the notice to the client. Should this
process happen in the API or from the broker?

3. for the iPhone wrapper of the mosquitto client, I checked
Marquette ,
is this wrapper compatible with the latest version of Mosquitto 1.0.2

I know this is quite complicated issue, but really hope can get some advice
on how to approach.

thanks a lot!

-Horace
-- 
Mailing list: https://launchpad.net/~mosquitto-users
Post to : mosquitto-users@lists.launchpad.net
Unsubscribe : https://launchpad.net/~mosquitto-users
More help   : https://help.launchpad.net/ListHelp


Re: [Mosquitto-users] Mosquitto+Python+MySQL+APNS

2012-09-18 Thread Yun Kong Tech
Thank you a lot Roger! really great suggestions on how to do it.

for the server side, i think my challenge will be how to add the database
storage functionality while:

   - making it still be able to easily compatible with future version of
   mosquitto and;
   - keeping it easier to support my own database scheme change/updates
   during the development/versioning cycles;

Ideally, i would just add few additional functions in the code to implement
the "database saving/reading" process.

Where should I do that? I think adding these methods in the python wrapper
of mosquitto is better in the lib itself, right? in this way I can
add/modify the broker functionality without messing with the original
source code of Mosquitto.

I will dig into your source code and try to figure out am I correct.

-Horace

On Tue, Sep 18, 2012 at 4:58 PM, Roger Light  wrote:

> Hi,
>
> >> 3. for the iPhone wrapper of the mosquitto client, I checked Marquette
> , is
> >> this wrapper compatible with the latest version of Mosquitto 1.0.2
> >
> > From what I can see, the last commit to Marquette was 8 months ago, so
> > unfortunately no it isn't compatible with 1.0.2.
>
> I'm sure that Nick would be very happy to receive pull requests
> updating it to 1.0.2 though!
>
> Cheers,
>
> Roger
>
-- 
Mailing list: https://launchpad.net/~mosquitto-users
Post to : mosquitto-users@lists.launchpad.net
Unsubscribe : https://launchpad.net/~mosquitto-users
More help   : https://help.launchpad.net/ListHelp


Re: [Mosquitto-users] Mosquitto+Python+MySQL+APNS

2012-09-18 Thread Yun Kong Tech
for the "client" you are talking about here, just want to make sure i
understand correctly:

what i should do is:

1. just run a *regular *broker as the original mosquitto broker on the
server side.* I should not modify it at all;*
2. meanwhile, i should implement a *special client* on the *server
side, *adding
the database saving functionality to it;
3. for all the messages received by the broker, the special client will
subscribe/receive it and store it to the database;
4. the broker will distribute the message to all the regular subscribers on
mobile client side.(should I add the database storing method on the mobile
mosquitto client, depending on do i need to do the same database saving
thing on mobile)

so the sole purpose of the *special client* on the server side is just
"saving the messages to database".


-Horace

On Tue, Sep 18, 2012 at 4:54 PM, Roger Light  wrote:

> Hi Yun,
>
> > 1. what's the best practice to connect Mosquitto broker with the MySQL to
> > make sure: all messages are stored in the database? Ideally, all message
> > sent to server should be stored in the db before they are distributed, to
> > ensure the data security.
>
> At the moment you have to write an MQTT client that subscribes to the
> appropriate topics and then stores the messages in your database. You
> can ensure the messages are stored in the database before being
> distributed by carefully separating the topics that clients publish
> and subscribe to. Your server side processing then acts as in the
> "subscribe, receive, process, republish" pattern - it receives the
> incoming message, saves it to the database and then republishes it to
> the appropriate recipients. You could even split this up - one (or
> more, depending on how you arrange it) server side client for
> processing the incoming messages and saving them to the database, then
> other server side clients to distribute the messages.
>
> > 2. when the server know one client is not active/connected, the server
> > should call the APNS service to send the notice to the client. Should
> this
> > process happen in the API or from the broker?
>
> This is where you will want to make use of the "last will and
> testament" (or just "will") feature. When your client connects, it
> sets up a Will message with the broker. When the client disconnects
> unexpectedly (i.e. without sending a DISCONNECT) the broker publishes
> the Will. A common way of using this is to publish "1" to a topic e.g.
> status/ when the client connects. The client also set up
> the Will to publish a "0" to status/ on unexpected
> disconnect. Your server side processing can then subscribe to status/#
> to determine the current connection status of all clients and use this
> information for determining how to distribute the message.
>
> > 3. for the iPhone wrapper of the mosquitto client, I checked Marquette ,
> is
> > this wrapper compatible with the latest version of Mosquitto 1.0.2
>
> From what I can see, the last commit to Marquette was 8 months ago, so
> unfortunately no it isn't compatible with 1.0.2. I would point out
> that libmosquitto compiles just fine under Objective C, although of
> course it isn't an Objective C interface.
>
> Cheers,
>
> Roger
>
> > I know this is quite complicated issue, but really hope can get some
> advice
> > on how to approach.
> >
> > thanks a lot!
> >
> > -Horace
> >
> > --
> > Mailing list: https://launchpad.net/~mosquitto-users
> > Post to : mosquitto-users@lists.launchpad.net
> > Unsubscribe : https://launchpad.net/~mosquitto-users
> > More help   : https://help.launchpad.net/ListHelp
> >
>
-- 
Mailing list: https://launchpad.net/~mosquitto-users
Post to : mosquitto-users@lists.launchpad.net
Unsubscribe : https://launchpad.net/~mosquitto-users
More help   : https://help.launchpad.net/ListHelp


Re: [Mosquitto-users] Version 1.0.5 released

2012-11-03 Thread Yun Kong Tech
thanks a lot Roger, already using it in my dev environment.

I noticed the package at homebrew is still 1.0.2.  will it be updated soon?
:)

On Sat, Nov 3, 2012 at 9:26 PM, Roger Light  wrote:

> Hi all,
>
> I've just released version 1.0.5:
> http://mosquitto.org/2012/11/version-1-0-5-released/
>
> Cheers,
>
> Roger
>
> --
> Mailing list: https://launchpad.net/~mosquitto-users
> Post to : mosquitto-users@lists.launchpad.net
> Unsubscribe : https://launchpad.net/~mosquitto-users
> More help   : https://help.launchpad.net/ListHelp
>
>
-- 
Mailing list: https://launchpad.net/~mosquitto-users
Post to : mosquitto-users@lists.launchpad.net
Unsubscribe : https://launchpad.net/~mosquitto-users
More help   : https://help.launchpad.net/ListHelp


[Mosquitto-users] Updated the Objective-C wrapper Marquette to support mosquitto 1.0.5

2012-11-05 Thread Yun Kong Tech
Since i was trying to use the latest library 1.0.5 on iOS development, I
updated the Marquette wrapper to support 1.0.5.

Tested with the basic functionality, no obvious problems. Still waiting for
Nick's approval on the pull request, hope he can come to check it out soon.

https://github.com/horacex/marquette

Enjoy,

-Horace
-- 
Mailing list: https://launchpad.net/~mosquitto-users
Post to : mosquitto-users@lists.launchpad.net
Unsubscribe : https://launchpad.net/~mosquitto-users
More help   : https://help.launchpad.net/ListHelp