<commit_before>
using System.Collections.Generic;
using System.Threading.Tasks;
using Flood.RPC.Serialization;
using System;

namespace Flood.RPC
{

    public abstract class RPCImpl : RPCStub
    {
        protected delegate Task DProcessCall(RPCData.Call call);
        protected delegate void DProcessSubscribe(RPCPeer peer, int localId, int remoteId, int delegateId);

        protected struct Processors
        {
            public DProcessCall Call;
            public DProcessSubscribe Subscribe;
            public DProcessSubscribe Unsubscribe;

            public Processors(DProcessCall call)
                : this()
            {
                Call = call;
            }

            public Processors(DProcessSubscribe subscribe, DProcessSubscribe unsubscribe)
                : this()
            {
                Subscribe = subscribe;
                Unsubscribe = unsubscribe;
            }
        }

        protected Dictionary<int, Processors> processors;

        public object Impl { get; set; }

        public RPCImpl(object impl, int id)
            : base(id)
        {
            Impl = impl;
            processors = new Dictionary<int, Processors>();
        }

        public void ProcessCall(RPCData.Call call)
        {
            var processCall = processors[call.MethodId].Call;
            if (processCall != null)
            {
                processCall(call);
            }
            else
            {
                SerializerUtil.Skip(call.Data.Serializer, TType.DataObject);
                var response = RPCData.Create(call.Data, RPCDataType.Exception);
                RPCException x = new RPCException(RPCException.ExceptionType.UnknownMethod, "Invalid method id: '" + call.MethodId + "'");
                response.Serializer.WriteI32(call.Id);
                x.Write(response.Serializer);
                response.Dispatch();
            }
        }

        internal void ProcessEventSubscribe(RPCData data)
        {
            var eventId = data.Serializer.ReadI32();
            var delegateId = data.Serializer.ReadI32();

            var subscribe = processors[eventId].Subscribe;
            if (subscribe == null)
                throw new Exception();

            subscribe(data.Peer, data.Header.LocalId,  data.Header.RemoteId, delegateId);
        }<commit_msg>Change subscribe signature it no longer requires a localId.<commit_after>
using System.Collections.Generic;
using System.Threading.Tasks;
using Flood.RPC.Serialization;
using System;

namespace Flood.RPC
{

    public abstract class RPCImpl : RPCStub
    {
        protected delegate Task DProcessCall(RPCData.Call call);
        protected delegate void DProcessSubscribe(RPCPeer peer, int remoteId, int remoteDelegateId);

        protected struct Processors
        {
            public DProcessCall Call;
            public DProcessSubscribe Subscribe;
            public DProcessSubscribe Unsubscribe;

            public Processors(DProcessCall call)
                : this()
            {
                Call = call;
            }

            public Processors(DProcessSubscribe subscribe, DProcessSubscribe unsubscribe)
                : this()
            {
                Subscribe = subscribe;
                Unsubscribe = unsubscribe;
            }
        }

        protected Dictionary<int, Processors> processors;

        public object Impl { get; set; }

        public RPCImpl(object impl, int id)
            : base(id)
        {
            Impl = impl;
            processors = new Dictionary<int, Processors>();
        }

        public void ProcessCall(RPCData.Call call)
        {
            var processCall = processors[call.MethodId].Call;
            if (processCall != null)
            {
                processCall(call);
            }
            else
            {
                SerializerUtil.Skip(call.Data.Serializer, TType.DataObject);
                var response = RPCData.Create(call.Data, RPCDataType.Exception);
                RPCException x = new RPCException(RPCException.ExceptionType.UnknownMethod, "Invalid method id: '" + call.MethodId + "'");
                response.Serializer.WriteI32(call.Id);
                x.Write(response.Serializer);
                response.Dispatch();
            }
        }

        internal void ProcessEventSubscribe(RPCData data)
        {
            var eventId = data.Serializer.ReadI32();
            var remoteDelegateId = data.Serializer.ReadI32();

            var subscribe = processors[eventId].Subscribe;
            if (subscribe == null)
                throw new Exception();

            subscribe(data.Peer, data.Header.RemoteId, remoteDelegateId);
        }
{'fraction_non_alphanumeric': 0.07895296871674824, 'fraction_numerical': 0.002553734837199404, 'mean_word_length': 1.7421236872812136, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '6179739', 'n_tokens_mistral': 1186, 'n_tokens_neox': 1095, 'n_words': 271}