-1

I am creating an multiplayer server based on photon using CRJ Gaming tutorials i have ran into this error, been trying to fix it for more than 2 hours, rewatched tutorials few times, i am completely lost.

Erorr:

Error   1   'FPS.Photon.Server.PhotonServerHandler' does not implement interface member 'FPS.Framework.IHandler<FPS.Photon.Server.PhotonServerPeer>.HandleMessage(FPS.Framework.IMessage, FPS.Photon.Server.PhotonServerPeer)'  C:\Users\Blagovest\documents\visual studio 2013\Projects\FPS\FPS.Photon\Server\PhotonServerHandler.cs   12  27  FPS.Photon

PhotonServerHandler

using ExitGames.Logging;
using FPS.Framework;
using FPS.Photon.Application;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace FPS.Photon.Server
{
    public abstract class PhotonServerHandler : IHandler<PhotonServerPeer>
    {
        public abstract MessageType Type { get; }
        public abstract byte Code { get; }
        public abstract int? SubCode { get; }
        protected PhotonApplication Server;
        protected ILogger Log = LogManager.GetCurrentClassLogger();

        public PhotonServerHandler(PhotonApplication application)
        {
            Server = application;
        }

        public bool HandleMessge(IMessage message, PhotonServerPeer serverPeer)
        {
            OnHandleMessage(message, serverPeer);
            return true;
        }

        protected abstract bool OnHandleMessage(IMessage message, PhotonServerPeer serverPeer);
    }
}

PhotonServerPeer

using FPS.Photon.Application;
using Photon.SocketServer;
using Photon.SocketServer.ServerToServer;
using PhotonHostRuntimeInterfaces;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace FPS.Photon.Server
{
    public class PhotonServerPeer : ServerPeerBase
    {
        private readonly PhotonServerHandlerList _handlerList;
        protected readonly PhotonApplication Server;
        public Guid? ServerId { get; set; }
        public string TcpAddress { get; set; }
        public string UdpAddress { get; set; }
        public string ApplicationName { get; set; }
        public int ServerType { get; set; }

        #region Factory Method

        public delegate PhotonServerPeer Factory(IRpcProtocol protocol, IPhotonPeer photonPeer);

        #endregion

        public PhotonServerPeer(IRpcProtocol protocol, IPhotonPeer photonPeer, PhotonServerHandlerList handlerList, PhotonApplication application) : base(protocol, photonPeer)
        {
            _handlerList = handlerList;
            Server = application;
        }

        protected override void OnOperationRequest(OperationRequest operationRequest, SendParameters sendParameters)
        {
            _handlerList.HandleMessage(new PhotonRequest(operationRequest.OperationCode, operationRequest.Parameters.ContainsKey(Server.SubCodeParameterKey) ? (int?)Convert.ToInt32(operationRequest.Parameters[Server.SubCodeParameterKey]) : null, operationRequest.Parameters), this);
        }

        protected override void OnEvent(IEventData eventData, SendParameters sendParameters)
        {
            _handlerList.HandleMessage(new PhotonEvent(eventData.Code, eventData.Parameters.ContainsKey(Server.SubCodeParameterKey) ? (int?)Convert.ToInt32(eventData.Parameters[Server.SubCodeParameterKey]) : null, eventData.Parameters), this);
        }

        protected override void OnOperationResponse(OperationResponse operationResponse, SendParameters sendParameters)
        {
            _handlerList.HandleMessage(new PhotonResponse(operationResponse.OperationCode, operationResponse.Parameters.ContainsKey(Server.SubCodeParameterKey) ? (int?)Convert.ToInt32(operationResponse.Parameters[Server.SubCodeParameterKey]) : null, operationResponse.Parameters, operationResponse.DebugMessage, operationResponse.ReturnCode), this);
        }

        protected override void OnDisconnect(DisconnectReason reasonCode, string reasonDetail)
        {
            Server.ConnectionCollection.OnDisconnect(this);
        }

    }
}
Pencho Slaveikov
  • 175
  • 5
  • 12

1 Answers1

0

The error message gives you everything you need to know.

PhotonServerHandler is an abstract class which implements the interface IHandler

This means that all methods that are declared within the IHandler, must be implemented within PhotonServerHandler.

Here is a solid example of why you would get that error

public interface A
{
    void DoThingOne();
    void DoThingTwo();
} 

public abstract class B : A
{
    DoThingOne()
}

The above would throw an error.

If you are using visual studio, try right clicking on the interface, then implement interface.

that should implement all the necessary methods from the interface.