J2ME multiplayer game considerations

xiaoxiao2021-03-14  191

J2ME multiplayer game considerations

MIDP communication technology

1. http:

When you configure the HTTP stream MIDlet when you configure the HTTP stream MIDlet, don't try to send a small data at a time: what you will receive before you have finished all the data.

When sending an HTTP response from the server to be delayed to an event, the development connection in the mobile network may be expensive, usually due to the timeout, this situation is more prone to occurred on the Internet.

Mobile phones typically do not have resources to support multiple open HTTP connections. The overhead in the data structure and data cache is very large.

HTTP method

GET: Used to request a static resource to the server, repeating a GET request will get the same resource response. The GET request only provides the URL of the resource, does not include any message body.

POST: Used to request a dynamic resource to the server (such as a round in the game), repeating a POST request will get a different resource response. The POST response also includes a message body with a service response data, which is a common method of MIDlet.

The HTTP response from a server may include a status code such as success (2xx), redirect (3xx), or error (4xx, 5xx). These code need to be processed by the HTTP client.

HTTP Message

The information sent is only a string byte stream, and these bytes can be encoded, including:

Text; image file (at least support for PNG decoding); XML; other user custom data structures.

HTTP session

The server traces a series of continuous requests initiated by the MIDlet as an HTTP session. Because the HTTP itself is stateless, session management must be implemented on the HTTP protocol layer.

Method 1: Various sessions cookies.

Method 2: URL rewriting.

Because cookies have other uses, the full MIDlet implementation of session cookies is more complicated, and the URL is simple.

HTTP server

There are a variety of options including Java Servlet, JSP, ASP, ASP.NET, CGI Script.

2. TCP:

HTTP on the Internet usually implements TCP, the endpoint of TCP connection is a socket Socket. MIDP 1.0 does not include support for TCP, MIDP 2.0 specifies support for TCP, manufacturers can choose whether to include this support.

3. UDP:

When using UDP, the Datagram sent between the two devices that are communicating is often referred to as a data packet, and the MIDP 1.0 does not include support for UDP. MIDP 2.0 specifies support for UDP, manufacturing Merchants can choose whether to include this support. When implemented on a packet switching protocol such as GPRS, considering the response time of the mobile network, the amount of the package is generally not required to exceed one per second, and pay attention to the size of the package.

4. Serial cable

Support is implemented through the interface SerialPortConnection in MIDP 2.0.

5. Infrared

Support is implemented through the interface SerialPortConnection in MIDP 2.0.

6. Bluetooth (MIDP optional package communication technology)

A short-range wireless technology supports up to 8 devices in about 10 meters, and the response time is short, which is very suitable for multiplayer games (due to the transmission of Bluetooth super-direction, there is no need to be correct).

7. SMS short message service

SMS (Short Message Service) can send text messages or binary data, is a "storage forwarding" technology. Save the message through a Short Message Service Center (SMSC) in the queue and forward it later.

8. MMS multimedia message service

It is an upgraded version of SMS, allowing a message to be divided into several parts, including text, pictures, sounds, and videos, is also a "storage forwarding" technology. The MMS implementation uses SMS and HTTP.

Two game server technology HTTP and HTTPS

At the server side, you can use any techniques commonly used for HTTP servers such as static web, CGI, ASP, Java Servlet, and JavaServer Page (JSP). Java programmers typically choose Java servlet.

Three game types and related considerations

Multi-player single game & round game:

This game is characterized by players, and is not used by the network, and will not be restricted by the network.

Cycling game & simultaneous action game:

When using MIDP 1.0, you can select HTTP, but HTTP has a major disadvantage. The game server cannot inform the MIDP client: Now it is now, so the client must test, time to ask the game server: I am going to me, so I should consider Provide a scheme that interrupts waiting and starting the next query immediately.

MIDP 2.0, TCP may be the best choice. When the turn is a player, the server will immediately notify him, which is important, so UDP may not be suitable. In addition, in the cycle, the additional delay that TCP can cause is not a problem.

"Play" Type Game:

If the game involves real-time actions, the delay of HTTP will appear too serious. UDP, TCP, or two combinations should be considered when using MIDP 2.0. The latency of the mobile network is too much influence on fast and real-time multiplayer interaction.

Four people play common feature

Permanent user account

Game Hall (Lobby)

High score table

Players talk

Show delay ...

Yellow leaves (www.hyweb.net notebook)

转载请注明原文地址:https://www.9cbs.com/read-129369.html

New Post(0)