<commit_before>const { Endpoint, nativeGlobalNames } = require('westfield-endpoint')
const { Epoll } = require('epoll')

const NativeClientSession = require('./NativeClientSession')

class NativeCompositorSession {
  /**
   * @param {RtcClient}rtcClient
   * @returns {NativeCompositorSession}
   */
  static create (rtcClient) {
    const compositorSession = new NativeCompositorSession(rtcClient)

    // TODO move global create/destroy callback implementations into Endpoint.js
    compositorSession.wlDisplay = Endpoint.createDisplay(
      wlClient => compositorSession._onClientCreated(wlClient),
      globalName => compositorSession._onGlobalCreated(globalName),
      globalName => compositorSession._onGlobalDestroyed(globalName)
    )
    Endpoint.initShm(compositorSession.wlDisplay)
    compositorSession.wlDisplayName = Endpoint.addSocketAuto(compositorSession.wlDisplay)

    // set the wayland display to something non existing, else gstreamer will connect to us with a fallback value and
    // block, while in turn we wait for gstreamer, resulting in a deadlock!
    process.env.WAYLAND_DISPLAY = 'doesntExist'

    compositorSession.wlDisplayFd = Endpoint.getFd(compositorSession.wlDisplay)

    // TODO handle err
    const fdWatcher = new Epoll(err => Endpoint.dispatchRequests(compositorSession.wlDisplay))<commit_msg>add logging on which display we start a compositor<commit_after>const { Endpoint, nativeGlobalNames } = require('westfield-endpoint')
const { Epoll } = require('epoll')

const NativeClientSession = require('./NativeClientSession')

class NativeCompositorSession {
  /**
   * @param {RtcClient}rtcClient
   * @returns {NativeCompositorSession}
   */
  static create (rtcClient) {
    const compositorSession = new NativeCompositorSession(rtcClient)

    // TODO move global create/destroy callback implementations into Endpoint.js
    compositorSession.wlDisplay = Endpoint.createDisplay(
      wlClient => compositorSession._onClientCreated(wlClient),
      globalName => compositorSession._onGlobalCreated(globalName),
      globalName => compositorSession._onGlobalDestroyed(globalName)
    )
    Endpoint.initShm(compositorSession.wlDisplay)
    compositorSession.wlDisplayName = Endpoint.addSocketAuto(compositorSession.wlDisplay)
    console.log(`[app-endpoint-${rtcClient.appEndpointCompositorPair.appEndpointSessionId}] Native compositor session: new wayland end-point created: ${compositorSession.wlDisplayName}.`)

    // set the wayland display to something non existing, else gstreamer will connect to us with a fallback value and
    // block, while in turn we wait for gstreamer, resulting in a deadlock!
    process.env.WAYLAND_DISPLAY = 'doesntExist'

    compositorSession.wlDisplayFd = Endpoint.getFd(compositorSession.wlDisplay)

    // TODO handle err
    const fdWatcher = new Epoll(err => Endpoint.dispatchRequests(compositorSession.wlDisplay))
{'fraction_non_alphanumeric': 0.0846815834767642, 'fraction_numerical': 0.0, 'mean_word_length': 4.954918032786885, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2879833', 'n_tokens_mistral': 805, 'n_tokens_neox': 798, 'n_words': 186}