-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
77 additions
and
342 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
gui/src/main/java/com/github/kuangcp/tank/ws/WsBizHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package com.github.kuangcp.tank.ws; | ||
|
||
import com.github.kuangcp.tank.mgr.PlayStageMgr; | ||
import com.github.kuangcp.tank.util.HoldingKeyStateMgr; | ||
import com.github.kuangcp.tank.util.Json; | ||
import com.github.kuangcp.tank.ws.msg.MsgPack; | ||
import com.github.kuangcp.websocket.WsServerConfig; | ||
import com.github.kuangcp.websocket.handler.AbstractBizHandler; | ||
import io.netty.channel.ChannelHandler; | ||
import io.netty.channel.ChannelHandlerContext; | ||
import io.netty.handler.codec.http.websocketx.TextWebSocketFrame; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.apache.commons.lang3.BooleanUtils; | ||
|
||
/** | ||
* @author <a href="https://github.com/kuangcp">Kuangcp</a> on 2024-07-13 00:40 | ||
*/ | ||
@Slf4j | ||
@ChannelHandler.Sharable | ||
public class WsBizHandler extends AbstractBizHandler { | ||
|
||
public WsBizHandler(WsServerConfig config) { | ||
super(config); | ||
} | ||
|
||
@Override | ||
public void connectSuccess(Long userId) { | ||
log.info("CONN userId={}", userId); | ||
} | ||
|
||
@Override | ||
protected void textWebSocketFrameHandler(ChannelHandlerContext ctx, TextWebSocketFrame frame) { | ||
final String text = frame.text(); | ||
final MsgPack pack = Json.fromJson(text, MsgPack.class); | ||
|
||
HoldingKeyStateMgr.instance.handleJoy(pack.getDirect()); | ||
if (BooleanUtils.isTrue(pack.getShot())) { | ||
PlayStageMgr.instance.hero.shotEnemy(); | ||
} | ||
|
||
ctx.channel().writeAndFlush("OK"); | ||
} | ||
} |
36 changes: 0 additions & 36 deletions
36
gui/src/main/java/com/github/kuangcp/tank/ws/WsChannelInitializer.java
This file was deleted.
Oops, something went wrong.
51 changes: 0 additions & 51 deletions
51
gui/src/main/java/com/github/kuangcp/tank/ws/WsChannelSupervise.java
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.