Skip to content
Ben edited this page May 13, 2017 · 3 revisions

网络与操作分层 网络与操作分层

server side

sequenceDiagram
    Server->>+Client1: Broadcast
    Server->>+Client2: Broadcast
    Client1-->>-Server: VER0.81
    Client2-->>-Server: VER0.81
    Server->>+Client1: PLAYERID-1  
    Server->>+Client2: PLAYERID-2
    Client1-->>-Server: 1--PLAYERID-1--3-CRT-AIR-386-483--5-CRT-TRP-388-322----
    Client2-->>-Server: 1--PLAYERID-2--2-CRT-AIR-111-222--3-CRT-TRP-111-223----
    Server->>+Client1: 1--PLAYERID-1--3-CRT-AIR-386-483--5-CRT-TRP-388-322--PLAYERID-2--2-CRT-AIR-111-222--3-CRT-TRP-111-223----
    Server->>+Client2: 1--PLAYERID-1--3-CRT-AIR-386-483--5-CRT-TRP-388-322----PLAYERID-2--2-CRT-AIR-111-222--3-CRT-TRP-111-223----
    Client1-->>-Server: 2--PLAYERID-1--3-MOV-111-200--3-ATK-2-2----
    Client2-->>-Server: 2--PLAYERID-2--2-MOV-23-21--4-CRT-AIR-543-432----
    loop Reply Keyframe
        Client2-->Server: OPT
    end
    
Loading

说明:协议格式,除握手外,其余格式:

第几关键帧--PLAYERID-玩家id--单位id-命令-[命令操作数-[[更多操作数]-..]]--单位id-命令-[命令操作数-[[更多操作数]-..]]----

图表例子说明:1--PLAYERID-1--3-CRT-AIR-386-483--5-CRT-TRP-388-322---- 第一关键帧,玩家一;创造一个飞机在(368,483)并设其id为3;创造一个步兵在(388,322)并设其id为5;

2--PLAYERID-2--2-MOV-23-21--4-CRT-AIR-543-432---- 第二关键帧,玩家二;将id为2的单位移动到(23,21);创造一个飞机在(543,432)并设其id为5;

3-ATK-2-2----id为3的单位攻击玩家2id为2的单位;