# Best way to handle sockets and multiple scenes?

**URL:** <https://phaser.discourse.group/t/best-way-to-handle-sockets-and-multiple-scenes/4996>\
**Category:** Phaser 3\
**Created:** [January 26, 2020, 3:26am UTC](https://phaser.discourse.group/t/best-way-to-handle-sockets-and-multiple-scenes/4996 "2020-01-26T03:26:45Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![weaponstheyfear](https://avatars.discourse-cdn.com/v4/letter/w/ccd318/32.png) [@weaponstheyfear](https://phaser.discourse.group/u/weaponstheyfear)\
**Post date:** [January 26, 2020, 3:26am UTC](https://phaser.discourse.group/t/best-way-to-handle-sockets-and-multiple-scenes/4996/1 "2020-01-26T03:26:45Z")

</div>

I’m rather new to Phaser and a bit confused with multiple scenes sharing my socket connection. My game currently uses one large Scene class, but I’d like to break it up into a connection, login, main game and editor scene, all of which will need the websocket object.

What would be the best way to handle this? If it matters, this is how I am initializing my game.

```
const config = {
    type: Phaser.AUTO,
    scale: {
        mode: Phaser.Scale.FIT,
        autoCenter: Phaser.Scale.CENTER_BOTH,
        parent: "thegame",
        //width: window.innerWidth,
        width: 1024,
        height: 600,
        backgroundColor: '#ffffff',
    },
    scene: [
        GameScene
    ]
}

class Game extends Phaser.Game {
    constructor(config) {
        super(config)
    }
}
window.addEventListener('load', function () {
    let game = new Game(config)
})
```

---

<div class="post-metadata">

**Author:** ![samme](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/samme/32/5275_2.png) [@samme](https://phaser.discourse.group/u/samme)\
**Post date:** [January 26, 2020, 4:07am UTC](https://phaser.discourse.group/t/best-way-to-handle-sockets-and-multiple-scenes/4996/2 "2020-01-26T04:07:50Z")

</div>

You can use

```javascript
this.registry.set('socket', …);
this.registry.get('socket') // etc.

```

from any scene.
