function open_same_leader() {
    var win = window.open('', '', '')
    win.opener = null
    win.document.write(`
<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8" />
        <meta name="viewport" content="width=device-width, initial-scale=1.0" />
        <title>主持人</title>
        <style>
            html,
            body {
                width: 100%;
                height: 100%;
                margin: 0;
                overflow: hidden;
            }
            .scene {
                width: 100%;
                height: 100%;
            }
        </style>
    </head>
    <body>
        <div id="scene" class="scene"></div>
        <script src="./libs/socket.io.min.v4.msgpack.js"></script>
        <script src="//4dkk.4dage.com/v4/www/sdk/kankan-sdk-deps.js?v=4.0.67"></script>
        <script src="//4dkk.4dage.com/v4/www/sdk/kankan-sdk.js?v=4.0.67"></script>
        <script>
            function createSocket(config) {
                return io('wss://test-socket.4dkankan.com', {
                    path: '/fsl-node',
                    query: {
                        role: config.role,
                        roomId: 'test-room',
                        userId: Date.now().toString(),
                        sceneNum: 't-YhBCzQr',
                        userLimitNum: 30,
                        from: 0,
                    },
                })
            }

            var socket1 = createSocket({ role: 'leader' })
            var kankan1 = new KanKan({
                dom: '#scene',
                num: 't-YhBCzQr',
            })
            kankan1.render()

            socket1.onAny((event, data) => {
                if(event == 'webSyncAction'){
                    kankan1.Broadcast.SameScreen.receive(data)
                }
            })
           
            kankan1.Broadcast.SameScreen.on('data', data => {
                socket1.emit('webSyncAction',data)
            })
            kankan1.Broadcast.SameScreen.start()
        </script>
    </body>
</html>`)
    win.document.close()
}

function open_same_customer() {
    var win = window.open('', '', '')
    win.opener = null
    win.document.write(`
<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8" />
        <meta name="viewport" content="width=device-width, initial-scale=1.0" />
        <title>客户</title>
        <style>
            html,
            body {
                width: 100%;
                height: 100%;
                margin: 0;
                overflow: hidden;
            }
            .scene {
                width: 100%;
                height: 100%;
            }
        </style>
    </head>
    <body>
        <div id="scene" class="scene"></div>
        <script src="./libs/socket.io.min.v4.msgpack.js"></script>
        <script src="//4dkk.4dage.com/v4/www/sdk/kankan-sdk-deps.js?v=4.0.67"></script>
        <script src="//4dkk.4dage.com/v4/www/sdk/kankan-sdk.js?v=4.0.67"></script>
        <script>
            function createSocket(config) {
                return io('wss://test-socket.4dkankan.com', {
                    path: '/fsl-node',
                    query: {
                        role: config.role,
                        roomId: 'test-room',
                        userId: Date.now().toString(),
                        sceneNum: 't-YhBCzQr',
                        userLimitNum: 30,
                        from: 0,
                    },
                })
            }

            var socket1 = createSocket({ role: 'customer' })
            

            var kankan1 = new KanKan({
                dom: '#scene',
                num: 't-YhBCzQr',
            })
            kankan1.render()

            socket1.onAny((event, data) => {
                if(event == 'webSyncAction'){
                    kankan1.Broadcast.SameScreen.receive(data)
                }
            })
           
            kankan1.Broadcast.SameScreen.on('data', data => {
                socket1.emit('webSyncAction',data)
            })
            kankan1.Broadcast.SameScreen.start()
        </script>
    </body>
</html>`)
    win.document.close()
}
