You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: room_signal.go
    path of file: ./repos/ion/apps/room/server
    
    the code of the file until where you have to start completion: package server

import (
	"errors"
	"io"

	log "github.com/pion/ion-log"
	room "github.com/pion/ion/apps/room/proto"
	"github.com/pion/ion/pkg/util"
	"google.golang.org/grpc/codes"
	"google.golang.org/grpc/status"
)

// RoomSignalService represents an RoomSignalService instance
type RoomSignalService struct {
	room.UnimplementedRoomSignalServer
	rs *RoomService
}

// NewRoomService creates a new room app server instance
func NewRoomSignalService(rs *RoomService) *RoomSignalService {
	s := &RoomSignalService{
		rs: rs,
	}
	return s
}

func (s *RoomSignalService) Signal(stream room.RoomSignal_SignalServer) error {
	var p *Peer = nil
	defer func() {
		if p != nil {
			p.Close()
		}
	}()

	for {
		req, err := stream.Recv()

		if err != nil {
			if err == io.EOF {
				return nil
			}

			errStatus, _ := status.FromError(err)
			if errStatus.Code() == codes.Canceled {
				return nil
			}

			log.Errorf("signal error %v %v", errStatus.Message(), errStatus.Code())
			return err
		}

		switch payload := req.Payload.(type) {
		case *room.Request_Join:
			log.Infof("[C->S]=%+v", payload)
			reply, peer, err := s.Join(payload, stream)
			if err != nil {
				log.Errorf("Join err: %v", err)
				return err
			}

			p = peer
			log.Infof("[S->C]=%+v", reply)
			err = stream.Send(&room.Reply{Payload: reply})
			if err != nil {
				log.Errorf("stream send error: %v", err)
			}
		case *room.Request_Leave:
			log.Infof("[C->S]=%+v", payload)
			reply, err := s.Leave(payload)
			if err != nil {
				log.Errorf("Leave err: %v", err)
				return err
			}
			log.Infof("[S->C]=%+v", reply)
			err = stream.Send(&room.Reply{Pay
    
func (s *RoomSignalService) Signal(stream room.RoomSignal_SignalServer) error {
	var p *Peer = nil
	defer func() {
		if p != nil {
			p.Close()
		}
	}()

	for {
		req, err := stream.Recv()

		if err != nil {
			if err == io.EOF {
				return nil
			}

			errStatus, _ := status.FromError(err)
			if errStatus.Code() == codes.Canceled {
				return nil
			}

			log.Errorf("signal error %v %v", errStatus.Message(), errStatus.Code())
			return err
		}

		switch payload := req.Payload.(type) {
		case *room.Request_Join:
			log.Infof("[C->S]=%+v", payload)
			reply, peer, err := s.Join(payload, stream)
			if err != nil {
				log.Errorf("Join err: %v", err)
				return err
			}

			p = peer
			log.Infof("[S->C]=%+v", reply)
			err = stream.Send(&room.Reply{Payload: reply})
			if err != nil {
				log.Errorf("stream send error: %v", err)
			}
		case *room.Request_Leave:
			log.Infof("[C->S]=%+v", payload)
			reply, err := s.Leave(payload)
			if err != nil {
				log.Errorf("Leave err: %v", err)
				return err
			}
			log.Infof("[S->C]=%+v", reply)
			err = stream.Send(&room.Reply{Payload: reply})
			if err != nil {
				log.Errorf("stream send error: %v", err)
			}
		case *room.Request_SendMessage:
			log.Infof("[C->S]=%+v", payload)
			reply, err := s.SendMessage(payload)
			if err != nil {
				log.Errorf("LockConference err: %v", err)
				return err
			}
			log.Infof("[S->C]=%+v", reply)
			err = stream.Send(&room.Reply{Payload: reply})
			if err != nil {
				log.Errorf("stream send error: %v", err)
			}

		case *room.Request_UpdateRoom:
			log.Infof("[C->S]=%+v", payload)
			reply, err := s.UpdateRoom(payload)
			if err != nil {
				log.Errorf("UpdateRoom err: %v", err)
				return err
			}
			log.Infof("[S->C]=%+v", reply)
			if err != nil {
				log.Errorf("stream send error: %v", err)
			}
		default:
			log.Errorf("unknown signal!! payload=%+v", payload)
		}
	}
}