简体   繁体   中英

How to receive a stream from Meteor server using DDP

I am developping a game that can be played on your mobile phone and viewd on the computer screen. The phone acts as a joystick.

The architecture :

  • Server Meteor
  • Client Meteor : browser and mobile
  • Client AS3 : Game

Up to now, my games have been very simple and a simple Collection to store all commands sent from the joystick (mobile) to the server has been faster enough.

My next game is a small car game, a race, the commands i store in the Collection are just not getting out quicker enough to make it playable.

My idea at the moment, is to stream joystick (mobile) input and not store it in a collection to make things fast. MeteorStreams package seams to do exactly this, and after testing, it works very well.

The problem ! The flash game is using DDP to get data from the server. The DDP protocol is very simple and as far as i can gather, it only accepts to "call" a server method or "sub" to a collection.

I do not know how get a stream from the Meteor server to the Flash DDP client WITHOUT using a Collection (Mondodb).

At the moment i am using the only library that i can find for a DDP client in AS3 from acidsound on github .

So, my questions :

  1. Is this the correct way to do what i am trying to do ?
  2. Is there a better way to stream data for a game from client > server > dd client ?
  3. Is it possible somehow to insert into a server method (callable from ddp) the stream received from the joystick and keeping it "open" on the Game Client side ?

Perhaps i have all this whrong and Meteor is just not the right tech for this project :)

I'm not an AS3 developer but it should be easy as it is in JS. What I would do in any other Meteor app would be (this will not answer your question though)

var myConnection = DDP.connect("http://things.meteor.com");
Things = new Mongo.Collection("things", {connection: myConnection});

Just by looking at https://github.com/acidsound/DDPClientAS3/blob/master/src/DdpClient.as I reckon you should be able to pass the URL as a variable in the DdpClient constructor.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM