Skip to content

"Location-switch" ๐Ÿ” utilizes WebSocket technology for live interactions ๐Ÿš€, featuring user identification ๐Ÿ‘ค, WASD movement ๐Ÿ•น๏ธ, chat messaging ๐Ÿ’ฌ, and a check-in system โœ…. User data is stored locally ๐Ÿ—ƒ๏ธ, allowing the server to push updates, messages, and check-in details to clients in real-time ๐Ÿ“ก.

License

Notifications You must be signed in to change notification settings

peterxcli/location-switch

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

67 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Websocket Project

( xxx ) ้ƒฝๆ˜ฏ้กๅค–็š„ๅŠŸ่ƒฝ

Features

  • User ๅ…ˆไปฅๆ‰€ๆœ‰็”จๆˆถ ( ๆœ‰ๆ™‚้–“ๅ†ๅŠ  DB , ่ผธๅ…ฅไฝฟ็”จ่€…ๅ็จฑ๏ผŒuniqe id )

  • WASD ็งปๅ‹•

  • ้ ญไธŠๅ†’ๆณกๆณก่จŠๆฏ๏ผš ๅณ้‚Šไธ€ๅ€‹ๅดๆฌ„ ๆ–‡ๅญ— ๏ผˆ ่ฒผๅœ– ๏ผ‰

  • ๆ‰“ๅก๏ผˆ ๅ‡บ็พไธ€ๅ€‹็ด…้ปž ้กžไผผ Google map ไธ€ๆจฃ้€้Žๅณ้‚Šๅดๆฌ„ ๅบ—ๅฎถ ๆ˜Ÿๆ˜Ÿๆ•ธ ่ท้›ข ๏ผˆ ๅˆ†ไบซ่ณ‡่จŠ ๏ผ‰

localstorage

  • username: str
  • userId : uuid4 ( from utils )

Actions

  • Client to backend :

    • interface : { 'event':'xxx' , .... }
    • event :
      • new_user
      • move
      • message
      • check_in
    • new_user :
      • { 'event':'new_user' , 'username' : 'jason' }
    • move :
      • { 'event':'move', 'pos' : [ 11.15,22.21 ] }
    • message :
      • { 'event':'message', 'message' : 'Hi all!' }
    • check_in :
      • { 'event':'check_in', 'pos' : [65.12,304.3], 'img' : 'image_url' , 'content' : 'Lunch :p', 'created_at': '2020-04-0 12:00:00' }
  • Backend to client :

    • event :
      • update
      • message
      • check_in
    • update
      • { 'event':'update' , 'username': 'jason', 'pos' : [11.22, 33.44] }
    • message
      • { 'event':'message' , 'username': 'jason', 'pos' : [11.22, 33.44], message: 'Hi all!' }
    • check_in
      • {'event': 'check_in', 'id': 'twjet-wrqwrwqe', 'user_id': 'fwefwe34wre', 'username': 'jason', 'pos': [11.22, 33.44], 'img': 'image_url', 'content': 'Lunch :p', 'created_at': '2020-04-0 12:00:00''}

schema

class userModel(TypedDict):
    id: Union[str, int]
    username: str
    pos: Tuple[float, float]
    message: str

backend ws routes

// TBD

Frontend state

TBD : Is mySelf state necessary ?

  • myself : dict

    { 'user' : 'ouo' , 'pos' : [11.22,33.44]}
    
  • users : dict

    { 
        'jason' , { 'pos' : [12.3,3.21] } ,
        'ouob' , { 'pos' : [12.3,3.21] },
    }
  • checkIn : list

    [ 
        { 'user' : 'jason', 'pos' : [11.22,33.44] , 'img' : 'image_url' , 'content' : 'Save water for beer!' } ,
        { 'user' : 'OuO', 'pos' : [11.22,33.44] , 'img' : 'image_url' , 'content' : 'ouo' } ,
    ]
    

UI

  • map
  • websocket

Backend

Reference

Leaflet.js ( open source map api )

Mask Map : Vue + Leaflet

How to change map center in leaflet.js

About

"Location-switch" ๐Ÿ” utilizes WebSocket technology for live interactions ๐Ÿš€, featuring user identification ๐Ÿ‘ค, WASD movement ๐Ÿ•น๏ธ, chat messaging ๐Ÿ’ฌ, and a check-in system โœ…. User data is stored locally ๐Ÿ—ƒ๏ธ, allowing the server to push updates, messages, and check-in details to clients in real-time ๐Ÿ“ก.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published