I am trying to develop a DISPLAY SYSTEM (PIS:Passenger Information System).Let me explain the problem .
The system includes LCDs that is located in Stations of Metro.The passenger can see the graphically movement of the trains .the sensors sense the train and send the information to our database .this information should be displayed on the LCD and the passengers can see the trains location and arrival time on the LCD,but where is my problem ?!!my project manager said to me the information should be displayed on the LCD using Adobe Flash .but my problem is how can send the information to SWF file .i googled it and i found i can use webservices but in fact i couldn't find any useful article about this could you please give me some help and method about this .
I should display the movement of trains of lcd ,so i should send the an array to swf.
You have a variety of options
Using URLLoader, which is basically AJAX sending text. You'd have to poll to the server though regularly. Any backend should be fine for this.
You could use AMF, which works similar to the option above. But binary data is send over HTTP, so it's more efficient, but the backend has to understand AMF as well.
You could use sockets, providing a simple two communication. The backend needs of course to be a socket server.
You could use web-sockets, which is basically the new cool way for full duplex communication. The backend has to implement the websockets protocol though. I used ws in the passed and was quite satisfied.
You can use SOAP based web services, but that is way to heavy and requires using Flex, if you want to use them out of the box.
My suggestion would be a simple REST server which gets accessed via URLLoader. In the ActionScript language reference, you find examples, which are sufficient for the client development.
On the other hand ... if the backend is already set up, ask the backend guys how to access the data - I mean the protocol - and implement the client with regards to the protocol being provided.
Related
I'm wondering if anyone has any recommendations for the best way to implement a command line interface to an existing Windows service.
Ideally, the following requirements can be met:
Supports .Net Core and works cross platform
Is self hosted (ie not a separate executable)
Is registered globally and available in any terminal (ie. > myApp doThis -please --prettyplease)
Can be piped through to a web interface for remote terminal access via existing web app
Is available via terminals on other local network devices
The big requirement is that this works cross platform and is not tied to Windows. Any recommendations are very much appreciated!!!
Questions that feature the phrase "what is the best" typically aren't a good fit for stackoverflow as they're subjective - there may be no right answer to your query, but maybe there will be some good ones.
One option that I've employed several times in the past is to implement something like a simple shell/command prompt, accessed via telnet. You simply open a listening socket (TcpListener) and accept text commands sent to it/write text to it, something like your first day's of programming, with console in and out stream printing. There are bucketloads of examples on the web of simple tcp servers so I won't provide any code here. In terms of your points:
Supports .Net Core and works cross platform
It's tcp based, this is intrinsic
Is self hosted (ie not a separate executable)
Starts when the app starts, hosted by the app, doesn't need any complex IPc
Is registered globally and available in any terminal (ie. > myApp doThis -please --prettyplease)
The firewall is probably the only thing stopping your remote device communicating
Call be piped through to a web interface for remote terminal access via existing web app
html5/web based implementations of telnet exist. Could also make a simple web interface out of it (treat the browser like telnet; Here's little difference between them, they both read and write tcp sockets, just the browser adds more text from the http protocol. You can filter that out and just get the interesting bit the user can vary (the URL))
Is available via terminals on other local network devices
Covered above
The last time I implemented this was on a server that was used by credit card terminals. It already had a listening socket and clients followed a strict protocol, so it was easy to detect when a message didn't match protocol and treat it as a command instead. The system grew to the point where the server was full remotely configurable via a simple telnet interface, new credit card ranges and routings could be added,debug printouts could be enabled and all traffic would be sent to the telnet client, certain card terminals could be monitored etc; it was nothin more than compsci101 stuff of command = streamreader.ReadLine(), if(command == "debug") Global.DebugLoggingStream = tcpWriterStream
It had a web interface too, based on HttpListener, that just provided a nicely formatted list of the most recent errors, some config settings etc.. some stuff is better on a web page in a table than in an 80char column format. Eventually I upgraded this to be more like the terminal; the user could end the URL with a command, the command would be carried out and the result put in an array. Each time the page was served he array was dumped, so it became a sort of command shell in itself, not requiring telnet. I kept the telnet interface because it was good for realtime debugging, watching messages as they happened etc but if you wanted to get really fancy, websockets exists today for that sort of thing.
Another thought struck me; perhaps most of this hard work has been done for you, if you can find a c# implementation of an irc server, paired with a web based irc client, it would provide a way to "chat" with your service (which is pretty much all a command shell is; a human having a text chat with a program)
I am looking forward to make a sort of a chat application using C# and WCF, yet before I start I wanted to clear a few things, so that I don't get carried in the wrong direction. :)
the application should be able to both make event ( send messages ) and listen to events ( receive messages ), therefor if I understand it right, the application should be both the client and the server at once?
what binding should I use? If I understand right, basicHttp binding hard to configure and is used when a WCF app needs to connect to non-WCF app? While for connecting two WCF apps its better to use NetTcpBinding?
how would this applications find each other, considering that they are running on different machines? should there be a central server, to which the app would connect first, saying "I'm user123, my IP is that and that, I'm free for chat" and look for other user IP addresses there? Or is there some other ways for apps to find each other without the central server?
maybe you could direct me to some examples or tutorials on this topic? ( tried googling, no luck ).
Thanks! :)
If your peers (machine that can operate as a client & server) are going to be behind NATs/firewalls then you will have a very very tough time building a chat application using WCF. If the peers will all be on the same network WCF is workable.
To write a chat application from scratch using WCF you will be re-inventing the wheel. Why not employ an existing protocol that's been designed precisely for the purpose such as XMPP. There are XMPP libraries around for .Net. You will need a central server but if you use XMPP you could feasibly piggyback onto one of the many existing free servers.
You can use netPeerTcpBinding.
See also:
http://blogs.interknowlogy.com/2009/08/05/building-a-really-simple-wcf-p2p-application/
http://msdn.microsoft.com/en-us/library/bb690929(v=vs.90).aspx
http://www.codeproject.com/KB/WCF/Chat_application_using_WC.aspx
There is no right and wrong answer to your question - it all depends on what you require. You then can choose the best architecture for your needs, and then the best technology for that architecture.
There are two things to consider - how will users find people to chat to, and then once they have found someone - how do the applications connect to each other.
For users to find each other, you either need to connect to a central server, which will then show a list of all connected users, or users need to enter the IP address of the person they want to chat to. Note that some firewalls will block incoming connections in this second case, so this may not be feasible in some cases.
Next, once you have found the person you wish to chat to, you need to decide whether messages will route directly to the other user, or if you want to continue to go through a central server.
If you choose to go through a central server, then your application will be functioning as a client, and will therefore pass through firewalls without a problem. However if you connect directly to the other user, both copies of the application will be acting as a client and a server (P2P topology), and therefore firewalls may be an issue. Having said that, you could designate one of the applications to be a server, with the other acting as a client, in which case only the server side needs to worry about the firewall.
Without knowing exactly what you are trying to achieve, it is hard to recommend which architecture will work best for you.
I want to write an app that sends an SMS to users, and when the recipients texts back, I receive that response, including the originating phone number, and my program can react to that response.
I've googled "Interactive SMS" but didn't find anything that was clearly a fit. Has anyone else done this, got any recommendations for a paid service that provides this kind of functionality?
Alternatively, do you have any other recommendations for how to build this service into my app, which will probably be written in C#?
Find an SMS service provider that gives you an API you can use (e.g. an HTTP API). Then read their documentation.
You need to learn about SMPP (short message peer to peer) protocol. Is the protocol usually used to communicate with carrier's SMSC (Short Message Service Center). Here's a blog entry summarizing the actual status of some C# SMPP libraries. If you don't want to use an existing .NET library, you can always write your own. SMPP is not a very complex protocol after all.
An alternative might be attach your application to a cell phone, and if that cell phone provides you with an API, use it to send and receive texts. The problem here is that it won't scale if your application expects to send and receive hundreds of thousands of text messages per day.
Yet another alternative will be to use a CARRIER AGGREGATOR company that provides you with an API for your application. There are some out there, but I don't know if they will be able to offer you a short code and the possibility to receive texts in your application. Depending on the market you are targeting, you should do a little bit of research on how other VAS companies do it over there.
You can use the TextMarks API for this. It's REST-based and super simple to use. So simple that Harvard uses it to teach new students how to use APIs. Docs here.
Messages routed to you from a user are called MO messages (Mobile Originated) and most 3rd party SMS gateways implement simple api's whereby they will simply HTTP post you incoming messages (including the originators msisdn and home network).
For example http://www.clickatell.com/products/two_way.php
Search the site for SMS Gateways for others.
Check SMS Studio - guys have done a lot on that subject and maybe you can use of-the-shelve software or customize it a little to suit your needs.
If not, at least you can find some good keywords for googling.
Anyway, you will have a choice - either go with SMS gateway, or for low volume SMS traffic, you can go with GSM Modem and handle it manually, though it's not recommended.
So I'm working on a project for my internship and have hit a bit of a brick wall. Unfortunately, the only people I know who are qualified to help me at the office are on vacation at the moment, and Google has been unfortunately unhelpful (or my search skills inadequate), so I thought I'd ask here.
The project is basically to make a server to mimic one that the company (which makes phone apps) already has. What I need to do is have one of their apps send a request to my server (I will have to modify the app to do this, but don't know how), and have my server reply with an XML response that the app already knows how to process. (The main purpose is so that we can see how the app responds when the real server sends it an error by simulating it on my server.)
Now, I already have a few sample HTTP requests and their associated XML responses handy, taken from simulations with the app and the real server. The app is written in C#, and currently sends HTTP web requests to the real server's online location, which responds to these HTTP web requests with XML. My server, however, will not have an online location, so the app will have to be modified to work with sockets on a local host.
My questions:
1) My boss said to create an XML file to associate certain requests with certain XML responses, but I have no idea what he means or how to do this. (He said it could also be done with a .ini file.) Does anyone know?
2) Once I have this XML file that can make these associations, how can I incorporate it into my server so that my server can check the request it received against its table of valid requests and figure out which response to send back?
3) How can one modify the app from using HTTP web requests and responses to using sockets?
If you have any questions/clarifications that you need in order to better answer this, please don't hesitate to ask me.
Thanks!
What you're describing is a web service. Unfortunately, his advice to change a setting in an .ini file make it sound like they have a proprietary system for doing this, rather than using a standard ASMX (which requires IIS) or WCF (which can either run in IIS or as a standalone service, which it sounds like is what you'd want) service.
Without more information about what they're using, I don't know that you'll be able to get much help here.
In response to question #3:
HTTP is a protocol that already runs on a specific socket (normally using port 80).
An internet socket is an endpoint that is used to transport data between processes. If you want to run your own protocol, you will need to create a new socket (with TCP or UDP) on a specific port.
This will however require you to create your own client and server in order to exchange data between them.
To get started, here is a very simple client-server example in C# using a custom socket.
Good luck!
Ask your boss if this client communicates with soap, if so then just go to MSDN and find tutorials on implementing an ASMX webservice, follow the tutorial through and you'll have a shell to start with.
First I'd like to say that it sounds like you have some unclear requirements that you should probably clarify with your boss. If you're not exactly sure what he means you should find out because nothing sucks more than having to support someone's creative interpretation of requirements.
1) It sounds like your boss just wants a way to easily change associations for testing without having to rebuild the app so he's asking you to store those associations in an xml/ini file that can easily be modified. In c# you can easily go between XML and DataSet objects so this should be trivial. I would create the data structure in a DataSet first and then use the GetXml method of the DataSet to output the xml format.
2) In .NET you can store objects in Cache and create a Cache Dependency that is a file association. Thus whenever the file is modified the Cache is purged. Whenever your program handles a request it pulls the object from Cache, if the object isn't in Cache then you have a condition block rebuild it from the xml/ini file on disk. I would have that condition block call out to a function that then loads the above mentioned xml format into a dataset that is then stored in the Cache with a Cache Dependency.
3) If you are trying to test an applications i/o, modifying it to use a different transport layer sounds like a bad idea. If the app currently works over HTTP to send requests then just route the HTTP request. I would suspect that the app probably has a configuration somewhere defining the path of the webservice it currently calls out to, once you know what that path is you can either change it, or if that's not possible setup a DNS rule on the server running the app to route it to the location of your application. On windows this is as simple as adding a line to the hosts file.
I'm writing a simple accounting program consists of several C# winform clients and a java server app that read/write data into a database. One of the requirement is that all C# clients should receive updates from the server. For example, if user a create a new invoice from his C# client, other users should see this new invoice from their client.
My experience is mainly on web development and I don't know what's the best way to fulfill this requirement with C#s client and Java servlet server.
My initial though is to run ActiveMQ with Glassfish and use messaging pub/sub method so that updates can be pushed to C# client. I will create different topics like newInvoice, cancelInvoice, etc in order to differentiate the message type. Each message will simply contains the object encoded in JSON.
But it seems to me that this involves quite a lot of work. Given that my user base is very small ( just 3 or 4 concurrent user), it seems to me that there should be some simpler solutions. (I'm not familiar socket programming :) )
I know this is a client-server programming 101 questions but would be great if any experienced programmer can point me to some simple solutions.
The simplest approach here is often to simply use a poll - i.e. have the clients query for data every (your time interval). That avoids a whole family of issues (firewalls, security, line-of-sight, resolution, client-tracking, etc).
With WCF, you can have callbacks on duplex channels (allowing the server to actively send a message to clients), but this is more complex. I value simplicity, so I usually just poll.
Tricks that help here are designing the system to have an inbuilt mechanism for querying "changes since x" - for example, an audit table, perhaps fed by database triggers. The exact details vary per project, of course.
Another option that you might want to look at is ADO.NET Sync Services; this does much of what you ask for, for keeping a local copy of the database up to date with the server - but has a few complexities of its own. This is available (IIRC) in the "Local Database Cache" VS template.
Rather than pushing information from the server to 1:N Clients, would it not be easier to have the clients Poll the server for updates every so often ? Or when the client launches and creates a connection to the server, the server could dynamically generate a new Message Queue for that Client Connection, which the client could then poll for updates?
There are several push technologies available to you, like ActiveMQ (as you mentioned), or XMPP. But if you only have 3 or 4 clients to concern yourself with, polling would be the simplest solution. It doesn't scale well, but that isn't really a concern in your case, unless your server is an 8086 or something 8-)
You may want to take a look at StreamHub Push Server - its a popular Comet server written in Java that has a .NET Client SDK for receiving updates from the server in C#. It also has a Java Client SDK and the usual Ajax/Comet web browser support giving you more flexibility in the future to push data to web, Java and C# clients.