문제

In a simple chat example using an APE Server and JavaScript on the client side which is pushing/polling information, is it possible to allow one user to upload a file (for example an image) and make the other users see that uploaded image, all in real time?

Thanks.

도움이 되었습니까?

해결책

Comet applications are generally used for text-based messaging. You could feasibly encode the image and send that data over the wire but the best practice would most likely be:

  1. User uploads the image to the application using normal web app file upload functionality
  2. Server receives the file, in addition to some instruction about telling other users about the file, and triggers and event information the other users that a new file is present. This event should also include the location of the file
  3. The other users receive the update, access the file location and then display the new file in the application

If 3. were a web app then you could dynamically create a new image an set the src attribute on it e.g. <img src="path_to_new_image" />.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top