# Path: server/rooms/models/participant.py
# class Participant(models.Model):
#     user = models.OneToOneField('accounts.User', blank=True, null=True,
#                                 related_name='participant')
#     session_key = models.CharField(max_length=32, blank=True, null=True)
#     name = models.CharField(max_length=64, blank=True, null=True)
# 
#     def get_display_name(self):
#         if self.name is None:
#             if self.user_id:
#                 return self.user.get_short_name()
#         return self.name
# 
#     objects = ParticipantManager()


import uuid
import json
from .models import Participant
from channels import Channel
        return self.manager.set_peer_data(self.id, key, value)

    def __getitem__(self, key):
        return self.manager.get_peer_data(self.id, key)

    @property
    def participant(self):
        if self._participant is None:
            self._participant = Participant.objects.get(
                id=self.manager.get_participant_id(self.id)
            )
        return self._participant

    @property
    def channel(self):
        return Channel(self['channel'])


class PeerManager:
    def __init__(self, redis_conn, room):
        self.redis_conn = redis_conn
        self.room = room

    @property
    def _prefix(self):
        return f'rooms:{self.room.id}'

    def for_participant(self, participant):
        peer_id = self.redis_conn.get(
            f'{self._prefix}:participants:{participant.id}:peer_id',

# Path: server/rooms/models/participant.py
# class Participant(models.Model):
#     user = models.OneToOneField('accounts.User', blank=True, null=True,
#                                 related_name='participant')
#     session_key = models.CharField(max_length=32, blank=True, null=True)
#     name = models.CharField(max_length=64, blank=True, null=True)
# 
#     def get_display_name(self):
#         if self.name is None:
#             if self.user_id:
#                 return self.user.get_short_name()
#         return self.name
# 
#     objects = ParticipantManager()


# Path: server/rooms/peers.py
import uuid
import json
from .models import Participant
from channels import Channel

        return self.manager.set_peer_data(self.id, key, value)

    def __getitem__(self, key):
        return self.manager.get_peer_data(self.id, key)

    @property
    def participant(self):
        if self._participant is None:
            self._participant = Participant.objects.get(
                id=self.manager.get_participant_id(self.id)
            )
        return self._participant

    @property
    def channel(self):
        return Channel(self['channel'])


class PeerManager:
    def __init__(self, redis_conn, room):
        self.redis_conn = redis_conn
        self.room = room

    @property
    def _prefix(self):
        return f'rooms:{self.room.id}'

    def for_participant(self, participant):
        peer_id = self.redis_conn.get(
            f'{self._prefix}:participants:{participant.id}:peer_id',

        )