Code Monkey home page Code Monkey logo

househackathonunityserver's People

Contributors

akubi0w1 avatar bambootuna avatar konnyaku256 avatar

Stargazers

 avatar  avatar

Watchers

 avatar

househackathonunityserver's Issues

Websocket対応について

概要

WebGLでプレイできるようにするために通信をWebsocketに移行
親と子どちらも一つのWebsocketコネクションを最後まで使う。

データ型

JoinRoomResponse

  1. roomId: String
  2. vagrant: Int

ReadyResponse

  1. roomId: String
  2. ghostRecord: List[Any]
  3. member: List[Member]
  4. yourDirection: Direction

Member(Object)

  1. accountName: String
  2. direction: Direction

Direction(Enum)

  1. "Up"
  2. "Down"
  3. "Left"
  4. "Right"

Coordinate

  1. x: Float
  2. y: Float
  3. z: Float
  4. elapsedTime: Int

Operation

  1. direction: Direction
  2. strength: Float

SendResultRequest

  1. ghostRecord: List[Coordinate]
  2. isGameClear: Boolean
  3. elapsedTime: Int

SimpleGameResult

  1. isGameClear: Boolean
  2. elapsedTime: Int

ErrorResponse

  1. errorType: ErrorType
  2. message: String

ErrorType(Enum)

  1. "RoomNotFound"
    ランダム参加にて部屋がない場合・合言葉が間違っている場合

  2. "LostConnection"
    ゲーム参加者のコネクションが切れた場合

  3. "MalformedMessageType"
    送信のデータ形式が間違っている場合

親の流れ

$ wscat -c "ws://localhost:18080/create_room?accountId=parent&accountName=parentName"
or
$ wscat -c "ws://localhost:18080/create_room?accountId=parent&accountName=parentName&roomKey=abc"

// 人が入ってきたらJoinRoomResponseが届く(JoinRoomResponse)
< {"roomId":"1f348ba9bf264296bc6fa87e55575781", "vagrant":3}
< {"roomId":"1f348ba9bf264296bc6fa87e55575781", "vagrant":2}
< {"roomId":"1f348ba9bf264296bc6fa87e55575781", "vagrant":1}
< {"roomId":"1f348ba9bf264296bc6fa87e55575781", "vagrant":0}

// 揃ったらReadyResponseが届く(ReadyResponse)
< 
{
    "roomId":"1f348ba9bf264296bc6fa87e55575781", 
    "yourDirection":"Up", 
    "member":[
        {
        "accountName":"parent",
        "direction":"Up"
        }, 
        {
        "accountName":"child1",
        "direction":"Down"
        }, 
        {
        "accountName":"child2",
        "direction":"Left"
        }, 
        {
        "accountName":"child3",
        "direction":"Right"
        }
    ]
}
// ゲームスタート

// 親はCoordinateを送信する(Coordinate)
> {"x":0.1, "y":0.1, "z":0.1, "elapsedTime":1}

// 子の操作情報が届く(Operation)
< {"direction":"Left", "strength":0.1}
< {"direction":"Down", "strength":0.1}
> {"x":0.1, "y":0.1, "z":0.1, "elapsedTime":2}
< {"direction":"Right", "strength":0.1}
> {"x":0.1, "y":0.1, "z":0.1, "elapsedTime":3}

// リザルトの送信(SendResultRequest)
> {"ghostRecord":[], "isGameClear":true, "elapsedTime":180}

子の流れ

$ wscat -c "ws://localhost:18080/join_room?accountId=child1&accountName=child1Name"
or
$ wscat -c "ws://localhost:18080/join_room?accountId=child1&accountName=child1Name&roomKey=abc"

// 人が入ってきたらJoinRoomResponseが届く(JoinRoomResponse)
< {"roomId":"1f348ba9bf264296bc6fa87e55575781", "vagrant":2}
< {"roomId":"1f348ba9bf264296bc6fa87e55575781", "vagrant":1}
< {"roomId":"1f348ba9bf264296bc6fa87e55575781", "vagrant":0}

// 揃ったらReadyResponseが届く(ReadyResponse)
< 
{
    "roomId":"1f348ba9bf264296bc6fa87e55575781", 
    "yourDirection":"Down", 
    "member":[
        {
        "accountName":"parent",
        "direction":"Up"
        }, 
        {
        "accountName":"child1",
        "direction":"Down"
        }, 
        {
        "accountName":"child2",
        "direction":"Left"
        }, 
        {
        "accountName":"child3",
        "direction":"Right"
        }
    ]
}

// ゲームスタート

// 親のCoordinate情報が届く(Coordinate)
< {"x":0.1, "y":0.1, "z":0.1, "elapsedTime":1}

// 子の操作情報を送信する(Operation)
> {"direction":"Down", "strength":0.1}
< {"x":0.1, "y":0.1, "z":0.1, "elapsedTime":2}
< {"x":0.1, "y":0.1, "z":0.1, "elapsedTime":3}

// リザルトが届く(SimpleGameResult)
< {"isGameClear":true, "elapsedTime":180}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.