Пример #1
0
        public void BuyMap(int mapPermission)
        {
            object[] pars = { mapPermission };
            APIMessage message = new APIMessage { Type = (int)enMessageType.EMT_CS_BuyMap, Parameters = pars };

            _ClientNet.SendMsg(message);
        }
Пример #2
0
        public IEnumerable <Concept> GetAllConcepts()
        {
            if (_project == null)
            {
                OutputPaneLogger.Error("Error occurred GetAllConcepts: _project is null");
                return(Enumerable.Empty <Concept>());
            }
            var gaugeApiConnection = GaugeService.Instance.GetApiConnectionFor(_project);

            if (gaugeApiConnection == null)
            {
                OutputPaneLogger.Error("Error occurred GetAllConcepts: apiConnection is null");
                return(Enumerable.Empty <Concept>());
            }
            var conceptsRequest = new GetAllConceptsRequest();
            var apiMessage      = new APIMessage
            {
                MessageId          = GenerateMessageId(),
                MessageType        = APIMessage.Types.APIMessageType.GetAllConceptsRequest,
                AllConceptsRequest = conceptsRequest
            };

            var bytes = gaugeApiConnection.WriteAndReadApiMessage(apiMessage);

            return(bytes.AllConceptsResponse.Concepts.Select(info => new Concept(_project)
            {
                StepText = info.StepValue.ParameterizedStepValue,
                StepValue = info.StepValue.StepValue,
                FilePath = info.Filepath,
                LineNumber = info.LineNumber
            }));
        }
Пример #3
0
        private static GaugeServiceClient GetGaugeServiceClient(string input, string parsedInput,
                                                                IGaugeService gaugeService,
                                                                EnvDTE.Project project)
        {
            var gaugeServiceClient = new GaugeServiceClient(gaugeService);
            var gaugeApiConnection = A.Fake <IGaugeApiConnection>();
            var response           = new APIMessage
            {
                MessageType       = APIMessage.Types.APIMessageType.GetStepValueResponse,
                MessageId         = 0,
                StepValueResponse = new GetStepValueResponse
                {
                    StepValue = new ProtoStepValue
                    {
                        ParameterizedStepValue = input,
                        StepValue = parsedInput
                    }
                }
            };

            A.CallTo(() => gaugeApiConnection.WriteAndReadApiMessage(A <APIMessage> ._))
            .Returns(response);
            A.CallTo(() => gaugeService.GetApiConnectionFor(project)).Returns(gaugeApiConnection);
            return(gaugeServiceClient);
        }
Пример #4
0
        public async Task <IActionResult> CreatePost(CreatePostResource postResource)
        {
            var apiResponse = new APIMessage();

            if (!ModelState.IsValid)
            {
                apiResponse.bit     = false;
                apiResponse.message = ModelState.ToString();
                return(BadRequest(apiResponse));
            }

            var post = mapper.Map <CreatePostResource, Post>(postResource);

            try
            {
                var user = await _userManager.GetUserAsync(User);

                var person = personService.GetPerson(user.Id);
                post.Person   = person;
                post.PersonId = person.Id;
                personService.AddPost(post);
                await unitOfWork.CompleteAsync();

                apiResponse.bit     = true;
                apiResponse.message = "your post has been added";
                return(Ok(apiResponse));
            }
            catch (Exception)
            {
                apiResponse.bit     = false;
                apiResponse.message = "cannot add post";
                return(BadRequest(apiResponse));
            }
        }
Пример #5
0
        public async Task <IActionResult> ReactPost(ReactResource reactResource)
        {
            var apiResponse = new APIMessage();

            if (!ModelState.IsValid)
            {
                apiResponse.bit     = false;
                apiResponse.message = ModelState.ToString();
                return(BadRequest(apiResponse));
            }


            var react = mapper.Map <ReactResource, React>(reactResource);

            try
            {
                var user = await _userManager.GetUserAsync(User);

                var person = personService.GetPerson(user.Id);
                react.Person        = person;
                react.PersonId      = person.Id;
                apiResponse.bit     = true;
                apiResponse.message = personService.ReactOnPost(react);
                await unitOfWork.CompleteAsync();

                return(Ok(apiResponse));
            }
            catch (Exception)
            {
                apiResponse.bit     = false;
                apiResponse.message = "cannot add react";
                return(BadRequest(apiResponse));
            }
        }
        private static APIMessage RefactorUsingGaugeDaemon(string newText, string originalText, Project project)
        {
            var performRefactoringRequest = new PerformRefactoringRequest
            {
                NewStep = newText,
                OldStep = originalText
            };
            var apiConnection = GaugeService.Instance.GetApiConnectionFor(project);

            if (apiConnection == null)
            {
                return(new APIMessage
                {
                    MessageId = 7,
                    MessageType = APIMessage.Types.APIMessageType.ErrorResponse,
                    Error = new ErrorResponse {
                        Error = "Gauge API Not Started"
                    }
                });
            }
            var apiMessage = new APIMessage
            {
                PerformRefactoringRequest = performRefactoringRequest,
                MessageType = APIMessage.Types.APIMessageType.PerformRefactoringRequest,
                MessageId   = 7
            };
            var response = apiConnection.WriteAndReadApiMessage(apiMessage);

            return(response);
        }
Пример #7
0
        public void ShouldGetParsedValueFromGauge()
        {
            const string expected = "foo message with {}";
            const string input    = "foo message with <parameter>";

            var gaugeService       = A.Fake <IGaugeService>();
            var project            = A.Fake <EnvDTE.Project>();
            var gaugeApiConnection = A.Fake <IGaugeApiConnection>();

            var response = new APIMessage
            {
                MessageType       = APIMessage.Types.APIMessageType.GetStepValueResponse,
                MessageId         = 0,
                StepValueResponse = new GetStepValueResponse
                {
                    StepValue = new ProtoStepValue
                    {
                        ParameterizedStepValue = input,
                        StepValue = expected
                    }
                }
            };

            A.CallTo(() => gaugeApiConnection.WriteAndReadApiMessage(A <APIMessage> ._))
            .Returns(response);
            A.CallTo(() => gaugeService.GetApiConnectionFor(project)).Returns(gaugeApiConnection);
            var gaugeServiceClient = new GaugeServiceClient(gaugeService);

            var actual = gaugeServiceClient.GetParsedStepValueFromInput(project, input);

            Assert.AreEqual(expected, actual);
        }
Пример #8
0
        private void OnSecurityCodeSent(APIMessage apiMessage)
        {
            inputField.text         = string.Empty;
            inputField.interactable = true;

            MessageSystem.QueueMessage(MessageDisplayData.Type.Success,
                                       apiMessage.message);
        }
Пример #9
0
 /// <summary>
 /// 调用函数.
 /// </summary>
 /// <param name="session"></param>
 /// <param name="msg"></param>
 /// <returns></returns>
 public Result Call(SessionBase session, APIMessage msg)
 {
     Result result = null;
     MessageHandler handler;
     _messageApilist.TryGetValue(msg.Type, out handler);
     if (handler == null)
         return result;
     result = handler(session, msg.Parameters);
     return result;
 }
        private static void ReloadChangedDocuments(APIMessage response)
        {
            var serviceProvider      = Package.GetGlobalService(typeof(IServiceProvider)) as IServiceProvider;
            var runningDocumentTable = new RunningDocumentTable(new ServiceProvider(serviceProvider));

            foreach (var file in response.PerformRefactoringResponse.FilesChanged)
            {
                var vsPersistDocData = runningDocumentTable.FindDocument(file) as IVsPersistDocData;
                vsPersistDocData?.ReloadDocData((uint)_VSRELOADDOCDATA.RDD_IgnoreNextFileChange);
            }
        }
Пример #11
0
        public IActionResult GetFeeDetails()
        {
            //var DeviceId = ((JObject)jObject).GetValue("deviceId", StringComparison.OrdinalIgnoreCase).Value<string>();
            //var GradeId = ((JObject)jObject).GetValue("gradeId", StringComparison.OrdinalIgnoreCase).Value<int>();
            List <Customers> customers  = this.customerService.GetCustomers();
            APIMessage       aPIMessage = new APIMessage {
                StatusCode = (int)HttpStatusCode.OK, StatusMessage = "Sucess great !!", Data = customers
            };

            //method: post, url : http://localhost:58272/api/customers/getdetails , Request body: { userId:10,deviceId:11,gradeId:22} , Content-Type: application/json
            return(StatusCode((int)HttpStatusCode.OK, customers));
        }
Пример #12
0
        protected override ValidationResult IsValid(object value, ValidationContext validationContext)
        {
            UserLogin userLogin = (UserLogin)validationContext.ObjectInstance;

            APIMessage apiMessage = APIInterface.IsUsernameInDb(userLogin.username).GetAwaiter().GetResult();

            if (apiMessage.Message == "That username is currently available.")
            {
                return(new ValidationResult("That username is not currently found in the database"));
            }

            return(ValidationResult.Success);
        }
        protected override ValidationResult IsValid(object value, ValidationContext validationContext)
        {
            var registerViewModel = (RegisterViewModel)validationContext.ObjectInstance;

            APIMessage apiMessage = APIInterface.IsSteamIdInDb(registerViewModel.SteamId).GetAwaiter().GetResult();

            if (apiMessage.Message == "User with that steam id already exists.")
            {
                return(new ValidationResult("That steam id is currently registered to another user"));
            }

            return(ValidationResult.Success);
        }
Пример #14
0
        public IEnumerable <ProtoSpec> GetSpecsFromGauge(IGaugeApiConnection apiConnection)
        {
            var specsRequest = new SpecsRequest();
            var apiMessage   = new APIMessage
            {
                MessageId    = GenerateMessageId(),
                MessageType  = APIMessage.Types.APIMessageType.SpecsRequest,
                SpecsRequest = specsRequest
            };

            var bytes = apiConnection.WriteAndReadApiMessage(apiMessage);

            var specs = bytes.SpecsResponse.Details.Where(detail => detail.Spec != null).Select(detail => detail.Spec);

            return(specs);
        }
 protected override void WndProc(ref Message m)
 {
     if (m.Msg == (int)WindowsMessages.WM_KEYDOWN)
     {
         if (ParentControl != null)
         {
             ParentControl.Focus();
             APIMessage.SendMessage(ParentControl.FindForm().Handle,
                                    m.Msg, m.WParam, m.LParam);
         }
     }
     else
     {
         base.WndProc(ref m);
     }
 }
Пример #16
0
        public ProtoStepValue GetStepValueFromInput(EnvDTE.Project project, string input)
        {
            var gaugeApiConnection = _gaugeService.GetApiConnectionFor(project);
            var stepsRequest       = new GetStepValueRequest {
                StepText = input
            };
            var apiMessage = new APIMessage
            {
                MessageId        = GenerateMessageId(),
                MessageType      = APIMessage.Types.APIMessageType.GetStepValueRequest,
                StepValueRequest = stepsRequest
            };

            var bytes = gaugeApiConnection.WriteAndReadApiMessage(apiMessage);

            return(bytes.StepValueResponse.StepValue);
        }
Пример #17
0
 public IEnumerable <string> GetStepValues(IEnumerable <string> stepTexts, bool hasInlineTable)
 {
     foreach (var stepText in stepTexts)
     {
         var stepValueRequest = GetStepValueRequest.CreateBuilder()
                                .SetStepText(stepText)
                                .SetHasInlineTable(hasInlineTable)
                                .Build();
         var stepValueRequestMessage = APIMessage.CreateBuilder()
                                       .SetMessageId(GenerateMessageId())
                                       .SetMessageType(APIMessage.Types.APIMessageType.GetStepValueRequest)
                                       .SetStepValueRequest(stepValueRequest)
                                       .Build();
         var apiMessage = WriteAndReadApiMessage(stepValueRequestMessage);
         yield return(apiMessage.StepValueResponse.StepValue.StepValue);
     }
 }
Пример #18
0
 public IEnumerable <string> GetStepValues(IEnumerable <string> stepTexts, bool hasInlineTable)
 {
     foreach (var stepText in stepTexts)
     {
         var stepValueRequest = new GetStepValueRequest()
         {
             StepText       = stepText,
             HasInlineTable = hasInlineTable
         };
         var stepValueRequestMessage = new APIMessage()
         {
             MessageId        = GenerateMessageId(),
             MessageType      = APIMessage.Types.APIMessageType.GetStepValueRequest,
             StepValueRequest = stepValueRequest,
         };
         var apiMessage = WriteAndReadApiMessage(stepValueRequestMessage);
         yield return(apiMessage.StepValueResponse.StepValue.StepValue);
     }
 }
Пример #19
0
        public void Hide(IWin32Window windowToActivate)
        {
            this._windowToActivate = windowToActivate;
            _handleToActivate      = this._windowToActivate != null ? this._windowToActivate.Handle : IntPtr.Zero;

            if (this._minimumDuration > 0)
            {
                this._waitingForTimer = true;
                if (!this._minimumDurationComplete)
                {
                    return;
                }
            }

            if (this._hwnd != IntPtr.Zero)
            {
                APIMessage.PostMessage(this._hwnd, (int)WindowMessages.WM_CLOSE, (uint)IntPtr.Zero, (uint)IntPtr.Zero);
            }
        }
Пример #20
0
        public IEnumerable <ProtoStepValue> GetAllStepsFromGauge(EnvDTE.Project project)
        {
            var gaugeApiConnection = _gaugeService.GetApiConnectionFor(project);

            if (gaugeApiConnection == null)
            {
                return(Enumerable.Empty <ProtoStepValue>());
            }
            var stepsRequest = new GetAllStepsRequest();
            var apiMessage   = new APIMessage
            {
                MessageId       = GenerateMessageId(),
                MessageType     = APIMessage.Types.APIMessageType.GetAllStepsRequest,
                AllStepsRequest = stepsRequest
            };

            var bytes = gaugeApiConnection.WriteAndReadApiMessage(apiMessage);

            return(bytes.AllStepsResponse.AllSteps);
        }
Пример #21
0
        /// <summary>Callback for a successful report submission.</summary>
        private void OnReportSuccessful(APIMessage response)
        {
            var messageData = new MessageDialog.Data()
            {
                header  = "Report Submission Status",
                message = "Report submission successful.\n" + response.message,
                standardButtonCallback = () =>
                {
                    ViewManager.instance.CloseWindowedView(ViewManager.instance.reportDialog);
                    ViewManager.instance.CloseWindowedView(ViewManager.instance.messageDialog);
                },
                standardButtonText = "Done",
                onClose            = () =>
                {
                    ViewManager.instance.CloseWindowedView(ViewManager.instance.reportDialog);
                    ViewManager.instance.CloseWindowedView(ViewManager.instance.messageDialog);
                },
            };

            ViewManager.instance.ShowMessageDialog(messageData);
        }
Пример #22
0
        /// <summary>Takes the remaining content of the stream and deserialze it into the instance.</summary>
        public static APIMessage.UserInfo Deserialize(Stream stream, APIMessage.UserInfo instance)
        {
            while (true)
            {
                int keyByte = stream.ReadByte();
                if (keyByte == -1)
                    break;
                // Optimized reading of known fields with field ID < 16
                switch (keyByte)
                {
                    // Field 1 LengthDelimited
                    case 10:
                        instance.Email = global::SilentOrbit.ProtocolBuffers.ProtocolParser.ReadString(stream);
                        continue;
                    // Field 2 LengthDelimited
                    case 18:
                        instance.Pass = global::SilentOrbit.ProtocolBuffers.ProtocolParser.ReadString(stream);
                        continue;
                    // Field 3 Varint
                    case 24:
                        instance.Cash = (int)global::SilentOrbit.ProtocolBuffers.ProtocolParser.ReadUInt64(stream);
                        continue;
                }

                var key = global::SilentOrbit.ProtocolBuffers.ProtocolParser.ReadKey((byte)keyByte, stream);

                // Reading field ID > 16 and unknown field ID/wire type combinations
                switch (key.Field)
                {
                    case 0:
                        throw new global::SilentOrbit.ProtocolBuffers.ProtocolBufferException("Invalid field id: 0, something went wrong in the stream");
                    default:
                        global::SilentOrbit.ProtocolBuffers.ProtocolParser.SkipKey(stream, key);
                        break;
                }
            }

            return instance;
        }
Пример #23
0
        private static void SplashThreadProcedure()
        {
            bool isOK = true;
            MSG  message;

            if (SplashScreen.splashWindowProcedure == null)
            {
                isOK = SplashScreen.current.RegisterWindowClass();
            }

            if (isOK)
            {
                isOK = SplashScreen.current.CreateNativeWindow();
            }

            if (isOK)
            {
                message = new MSG();

                while (APIMessage.GetMessage(ref message, IntPtr.Zero, 0, 0))
                {
                    APIMessage.TranslateMessage(ref message);
                    APIMessage.DispatchMessage(ref message);
                }

                SplashScreen.current._hwnd = IntPtr.Zero;

                if (SplashScreen.current._windowToActivate != null)
                {
                    if (SplashScreen.current._handleToActivate != IntPtr.Zero)
                    {
                        SplashScreen.Current._windowToActivate = null;
                        APIWindow.SetForegroundWindow(APIWindow.GetLastActivePopup(SplashScreen.current._handleToActivate));
                        APIPainting.RedrawWindow(SplashScreen.current._handleToActivate, IntPtr.Zero, IntPtr.Zero, (uint)0x85);
                        SplashScreen.current._handleToActivate = IntPtr.Zero;
                    }
                }
            }
        }
Пример #24
0
        public async Task <IActionResult> AddFriend(string userName)
        {
            var apiResponse = new APIMessage();

            if (!ModelState.IsValid)
            {
                apiResponse.bit     = false;
                apiResponse.message = ModelState.ToString();
                return(BadRequest(apiResponse));
            }

            try
            {
                var user = await _userManager.GetUserAsync(User);

                var person     = personService.GetPerson(user.Id);
                var userFriend = await _userManager.FindByNameAsync(userName);

                if (userFriend == null)
                {
                    apiResponse.bit     = false;
                    apiResponse.message = "cannot find user";
                    return(NotFound(apiResponse));
                }
                personService.AddFriend(person.Id, userFriend.Person.Id);
                await unitOfWork.CompleteAsync();

                apiResponse.bit     = true;
                apiResponse.message = "your and " + userFriend.UserName + " are now friends";
                return(Ok(apiResponse));
            }
            catch (Exception)
            {
                apiResponse.bit     = false;
                apiResponse.message = "cannot add friend";
                return(BadRequest(apiResponse));
            }
        }
Пример #25
0
        public async Task <IActionResult> DeletePost(int PostId)
        {
            var apiResponse = new APIMessage();

            if (!ModelState.IsValid)
            {
                apiResponse.bit     = false;
                apiResponse.message = ModelState.ToString();
                return(BadRequest(apiResponse));
            }
            try
            {
                var user = await _userManager.GetUserAsync(User);

                var person = personService.GetPerson(user.Id);
                if (personService.DeletePost(person.Id, PostId))
                {
                    await unitOfWork.CompleteAsync();

                    apiResponse.bit     = true;
                    apiResponse.message = "your post has been deleted";
                    return(Ok(apiResponse));
                }
                else
                {
                    apiResponse.bit     = false;
                    apiResponse.message = "cannot delete post";
                    return(NotFound(apiResponse));
                }
            }
            catch (Exception)
            {
                apiResponse.bit     = false;
                apiResponse.message = "cannot Delete post";
                return(BadRequest(apiResponse));
            }
        }
Пример #26
0
        /// <summary>Read the given number of bytes from the stream and deserialze it into the instance.</summary>
        public static APIMessage.UserCharacter DeserializeLength(Stream stream, int length, APIMessage.UserCharacter instance)
        {
            instance.CharacterClassType = APIMessage.CharacterClassType.WARRIOR;
            long limit = stream.Position + length;
            while (true)
            {
                if (stream.Position >= limit)
                {
                    if (stream.Position == limit)
                        break;
                    else
                        throw new global::SilentOrbit.ProtocolBuffers.ProtocolBufferException("Read past max limit");
                }
                int keyByte = stream.ReadByte();
                if (keyByte == -1)
                    throw new System.IO.EndOfStreamException();
                // Optimized reading of known fields with field ID < 16
                switch (keyByte)
                {
                    // Field 1 LengthDelimited
                    case 10:
                        instance.Name = global::SilentOrbit.ProtocolBuffers.ProtocolParser.ReadString(stream);
                        continue;
                    // Field 2 LengthDelimited
                    case 18:
                        instance.UserEmail = global::SilentOrbit.ProtocolBuffers.ProtocolParser.ReadString(stream);
                        continue;
                    // Field 3 Varint
                    case 24:
                        instance.CharacterClassType = (APIMessage.CharacterClassType)global::SilentOrbit.ProtocolBuffers.ProtocolParser.ReadUInt64(stream);
                        continue;
                    // Field 4 Varint
                    case 32:
                        instance.Level = (int)global::SilentOrbit.ProtocolBuffers.ProtocolParser.ReadUInt64(stream);
                        continue;
                    // Field 5 Varint
                    case 40:
                        instance.Exp = (int)global::SilentOrbit.ProtocolBuffers.ProtocolParser.ReadUInt64(stream);
                        continue;
                    // Field 6 Varint
                    case 48:
                        instance.Gold = (int)global::SilentOrbit.ProtocolBuffers.ProtocolParser.ReadUInt64(stream);
                        continue;
                    // Field 7 Varint
                    case 56:
                        instance.SkillPt = (int)global::SilentOrbit.ProtocolBuffers.ProtocolParser.ReadUInt64(stream);
                        continue;
                    // Field 8 Varint
                    case 64:
                        instance.StatsPt = (int)global::SilentOrbit.ProtocolBuffers.ProtocolParser.ReadUInt64(stream);
                        continue;
                    // Field 9 Varint
                    case 72:
                        instance.StrPt = (int)global::SilentOrbit.ProtocolBuffers.ProtocolParser.ReadUInt64(stream);
                        continue;
                    // Field 10 Varint
                    case 80:
                        instance.AgiPt = (int)global::SilentOrbit.ProtocolBuffers.ProtocolParser.ReadUInt64(stream);
                        continue;
                    // Field 11 Varint
                    case 88:
                        instance.IntPt = (int)global::SilentOrbit.ProtocolBuffers.ProtocolParser.ReadUInt64(stream);
                        continue;
                    // Field 12 Varint
                    case 96:
                        instance.StaPt = (int)global::SilentOrbit.ProtocolBuffers.ProtocolParser.ReadUInt64(stream);
                        continue;
                }

                var key = global::SilentOrbit.ProtocolBuffers.ProtocolParser.ReadKey((byte)keyByte, stream);

                // Reading field ID > 16 and unknown field ID/wire type combinations
                switch (key.Field)
                {
                    case 0:
                        throw new global::SilentOrbit.ProtocolBuffers.ProtocolBufferException("Invalid field id: 0, something went wrong in the stream");
                    default:
                        global::SilentOrbit.ProtocolBuffers.ProtocolParser.SkipKey(stream, key);
                        break;
                }
            }

            return instance;
        }
Пример #27
0
 /// <summary>Helper: put the buffer into a MemoryStream before deserializing</summary>
 public static APIMessage.UserInfo Deserialize(byte[] buffer, APIMessage.UserInfo instance)
 {
     using (var ms = new MemoryStream(buffer))
         Deserialize(ms, instance);
     return instance;
 }
Пример #28
0
        public bool SyncUserItem(int nItemIndex)
        {
            object[] pars = { nItemIndex };
            APIMessage message = new APIMessage { Type = (int)enMessageType.EMT_CS_UserItem, Parameters = pars };

            _ClientNet.SendMsg(message);
            return true;
        }
Пример #29
0
        /// <summary>Read the given number of bytes from the stream and deserialze it into the instance.</summary>
        public static APIMessage.Skill DeserializeLength(Stream stream, int length, APIMessage.Skill instance)
        {
            instance.DamageType = APIMessage.DamageType.PHYSICS;
            long limit = stream.Position + length;
            while (true)
            {
                if (stream.Position >= limit)
                {
                    if (stream.Position == limit)
                        break;
                    else
                        throw new global::SilentOrbit.ProtocolBuffers.ProtocolBufferException("Read past max limit");
                }
                int keyByte = stream.ReadByte();
                if (keyByte == -1)
                    throw new System.IO.EndOfStreamException();
                // Optimized reading of known fields with field ID < 16
                switch (keyByte)
                {
                    // Field 1 LengthDelimited
                    case 10:
                        instance.Id = global::SilentOrbit.ProtocolBuffers.ProtocolParser.ReadString(stream);
                        continue;
                    // Field 2 LengthDelimited
                    case 18:
                        instance.Name = global::SilentOrbit.ProtocolBuffers.ProtocolParser.ReadString(stream);
                        continue;
                    // Field 3 LengthDelimited
                    case 26:
                        instance.IconId = global::SilentOrbit.ProtocolBuffers.ProtocolParser.ReadString(stream);
                        continue;
                    // Field 4 Varint
                    case 32:
                        instance.CastTime = (int)global::SilentOrbit.ProtocolBuffers.ProtocolParser.ReadUInt64(stream);
                        continue;
                    // Field 5 Varint
                    case 40:
                        instance.CoolDown = (int)global::SilentOrbit.ProtocolBuffers.ProtocolParser.ReadUInt64(stream);
                        continue;
                    // Field 6 Varint
                    case 48:
                        instance.Cost = (int)global::SilentOrbit.ProtocolBuffers.ProtocolParser.ReadUInt64(stream);
                        continue;
                    // Field 7 Varint
                    case 56:
                        instance.MinDamage = (int)global::SilentOrbit.ProtocolBuffers.ProtocolParser.ReadUInt64(stream);
                        continue;
                    // Field 8 Varint
                    case 64:
                        instance.MaxDamage = (int)global::SilentOrbit.ProtocolBuffers.ProtocolParser.ReadUInt64(stream);
                        continue;
                    // Field 9 Varint
                    case 72:
                        instance.SkillFactor = (int)global::SilentOrbit.ProtocolBuffers.ProtocolParser.ReadUInt64(stream);
                        continue;
                    // Field 10 Varint
                    case 80:
                        instance.DamageType = (APIMessage.DamageType)global::SilentOrbit.ProtocolBuffers.ProtocolParser.ReadUInt64(stream);
                        continue;
                    // Field 11 LengthDelimited
                    case 90:
                        instance.Description = global::SilentOrbit.ProtocolBuffers.ProtocolParser.ReadString(stream);
                        continue;
                    // Field 12 LengthDelimited
                    case 98:
                        instance.SkillType = global::SilentOrbit.ProtocolBuffers.ProtocolParser.ReadString(stream);
                        continue;
                }

                var key = global::SilentOrbit.ProtocolBuffers.ProtocolParser.ReadKey((byte)keyByte, stream);

                // Reading field ID > 16 and unknown field ID/wire type combinations
                switch (key.Field)
                {
                    case 0:
                        throw new global::SilentOrbit.ProtocolBuffers.ProtocolBufferException("Invalid field id: 0, something went wrong in the stream");
                    default:
                        global::SilentOrbit.ProtocolBuffers.ProtocolParser.SkipKey(stream, key);
                        break;
                }
            }

            return instance;
        }
Пример #30
0
        /// <summary>Read the given number of bytes from the stream and deserialze it into the instance.</summary>
        public static APIMessage.SlotInventory DeserializeLength(Stream stream, int length, APIMessage.SlotInventory instance)
        {
            long limit = stream.Position + length;
            while (true)
            {
                if (stream.Position >= limit)
                {
                    if (stream.Position == limit)
                        break;
                    else
                        throw new global::SilentOrbit.ProtocolBuffers.ProtocolBufferException("Read past max limit");
                }
                int keyByte = stream.ReadByte();
                if (keyByte == -1)
                    throw new System.IO.EndOfStreamException();
                // Optimized reading of known fields with field ID < 16
                switch (keyByte)
                {
                    // Field 1 LengthDelimited
                    case 10:
                        instance.Id = global::SilentOrbit.ProtocolBuffers.ProtocolParser.ReadString(stream);
                        continue;
                    // Field 2 LengthDelimited
                    case 18:
                        instance.InventoryId = global::SilentOrbit.ProtocolBuffers.ProtocolParser.ReadString(stream);
                        continue;
                    // Field 3 LengthDelimited
                    case 26:
                        instance.ItemId = global::SilentOrbit.ProtocolBuffers.ProtocolParser.ReadString(stream);
                        continue;
                    // Field 4 Varint
                    case 32:
                        instance.Amount = (int)global::SilentOrbit.ProtocolBuffers.ProtocolParser.ReadUInt64(stream);
                        continue;
                }

                var key = global::SilentOrbit.ProtocolBuffers.ProtocolParser.ReadKey((byte)keyByte, stream);

                // Reading field ID > 16 and unknown field ID/wire type combinations
                switch (key.Field)
                {
                    case 0:
                        throw new global::SilentOrbit.ProtocolBuffers.ProtocolBufferException("Invalid field id: 0, something went wrong in the stream");
                    default:
                        global::SilentOrbit.ProtocolBuffers.ProtocolParser.SkipKey(stream, key);
                        break;
                }
            }

            return instance;
        }
Пример #31
0
        private APIMessage ReadMessage()
        {
            var responseBytes = ReadBytes();

            return(APIMessage.ParseFrom(responseBytes.ToArray()));
        }
Пример #32
0
        public bool LoadSceneFinish()
        {
            object[] pars = { };
            APIMessage message = new APIMessage { Type = (int)enMessageType.EMT_CS_LoadSceneFinish, Parameters = pars };

            _ClientNet.SendMsg(message);

            _matchResultInfoList.Clear();
            EMT_SC_MatchShowResultUI_nCount = -1;
            return true;
        }
Пример #33
0
        public bool CreateRole(string szRoleName, int nHeadID, short sSex)
        {
            object[] pars = {  szRoleName, nHeadID, sSex};
            APIMessage message = new APIMessage { Type = (int)enMessageType.EMT_CS_CreateRole, Parameters = pars };

               _ClientNet.SendMsg(message);
            return true;
        }
Пример #34
0
        public bool SelectRole(long lnRoleID)
        {
            object[] pars = { lnRoleID };
            APIMessage message = new APIMessage { Type = (int)enMessageType.EMT_CS_SelectRole, Parameters = pars };

            _ClientNet.SendMsg(message);
            return true;
        }
Пример #35
0
        public bool StartMatchingGame(int nTypeCount,int nSceneID)
        {
            _matchData.Clear();
            object[] pars = { nTypeCount, nSceneID };
            APIMessage message = new APIMessage { Type = (int)enMessageType.EMT_CS_StartMatching, Parameters = pars };

            _ClientNet.SendMsg(message);
            return true;
        }
Пример #36
0
        public bool StopMatchingGame()
        {
            object[] pars = { };
            APIMessage message = new APIMessage { Type = (int)enMessageType.EMT_CS_StopMatching, Parameters = pars };

            _ClientNet.SendMsg(message);
            return true;
        }
Пример #37
0
        private int SplashWindowProcedure(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam)
        {
            PAINTSTRUCT paintStruct;
            IntPtr      timerPtr;
            Graphics    graphics;

            if (msg <= (int)WindowMessages.WM_PAINT)
            {
                switch (msg)
                {
                case (int)WindowMessages.WM_CREATE:
                {
                    if (!this._transparencyKey.IsEmpty && this.IsLayeringSupported())
                    {
                        APIWindow.SetLayeredWindowAttributes(hwnd, (ulong)ColorTranslator.ToWin32(this._transparencyKey), (byte)0, LayeredWindowAttributesFlags.LWA_COLORKEY);
                    }

                    if (this._minimumDuration <= 0)
                    {
                        return(APIWindow.DefWindowProc(hwnd, msg, wParam, lParam));
                    }

                    this._timer = APITimer.SetTimer(hwnd, 1, this._minimumDuration, (TIMERPROC)null);
                    return(APIWindow.DefWindowProc(hwnd, msg, wParam, lParam));
                }

                case (int)WindowMessages.WM_DESTROY:
                {
                    APIMessage.PostQuitMessage(0);
                    return(APIWindow.DefWindowProc(hwnd, msg, wParam, lParam));
                }
                }

                if (msg == (int)WindowMessages.WM_PAINT)
                {
                    paintStruct = new PAINTSTRUCT();
                    timerPtr    = APIPainting.BeginPaint(hwnd, ref paintStruct);

                    if (timerPtr != IntPtr.Zero)
                    {
                        graphics = Graphics.FromHdcInternal(timerPtr);
                        graphics.DrawImage(this._image, 0, 0, this._width, this._height);

                        OnScreenCustomize(graphics);

                        graphics.Dispose();
                    }

                    APIPainting.EndPaint(hwnd, ref paintStruct);
                    return(0);
                }

                return(APIWindow.DefWindowProc(hwnd, msg, wParam, lParam));
            }

            if (msg == (int)WindowMessages.WM_ERASEBKGND)
            {
                return(1);
            }

            if (msg == (int)WindowMessages.WM_TIMER)
            {
                APITimer.KillTimer(hwnd, this._timer);
                this._timer = 0;
                this._minimumDurationComplete = true;

                if (this._waitingForTimer)
                {
                    APIMessage.PostMessage(hwnd, (int)WindowMessages.WM_CLOSE, (uint)IntPtr.Zero, (uint)IntPtr.Zero);
                }

                return(0);
            }

            return(APIWindow.DefWindowProc(hwnd, msg, wParam, lParam));
        }
Пример #38
0
        /// <summary>Read the given number of bytes from the stream and deserialze it into the instance.</summary>
        public static APIMessage.MasterCharacterClass DeserializeLength(Stream stream, int length, APIMessage.MasterCharacterClass instance)
        {
            BinaryReader br = new BinaryReader(stream);
            instance.CharacterClassType = APIMessage.CharacterClassType.WARRIOR;
            long limit = stream.Position + length;
            while (true)
            {
                if (stream.Position >= limit)
                {
                    if (stream.Position == limit)
                        break;
                    else
                        throw new global::SilentOrbit.ProtocolBuffers.ProtocolBufferException("Read past max limit");
                }
                int keyByte = stream.ReadByte();
                if (keyByte == -1)
                    throw new System.IO.EndOfStreamException();
                // Optimized reading of known fields with field ID < 16
                switch (keyByte)
                {
                    // Field 1 LengthDelimited
                    case 10:
                        instance.Id = global::SilentOrbit.ProtocolBuffers.ProtocolParser.ReadString(stream);
                        continue;
                    // Field 2 Varint
                    case 16:
                        instance.CharacterClassType = (APIMessage.CharacterClassType)global::SilentOrbit.ProtocolBuffers.ProtocolParser.ReadUInt64(stream);
                        continue;
                    // Field 3 Varint
                    case 24:
                        instance.HpBase = (int)global::SilentOrbit.ProtocolBuffers.ProtocolParser.ReadUInt64(stream);
                        continue;
                    // Field 4 Varint
                    case 32:
                        instance.SpBase = (int)global::SilentOrbit.ProtocolBuffers.ProtocolParser.ReadUInt64(stream);
                        continue;
                    // Field 5 Varint
                    case 40:
                        instance.AtkBase = (int)global::SilentOrbit.ProtocolBuffers.ProtocolParser.ReadUInt64(stream);
                        continue;
                    // Field 6 Varint
                    case 48:
                        instance.DefBase = (int)global::SilentOrbit.ProtocolBuffers.ProtocolParser.ReadUInt64(stream);
                        continue;
                    // Field 7 Fixed32
                    case 61:
                        instance.AtkSpdBase = br.ReadSingle();
                        continue;
                    // Field 8 Fixed32
                    case 69:
                        instance.MoveSpdBase = br.ReadSingle();
                        continue;
                    // Field 9 Varint
                    case 72:
                        instance.StrBase = (int)global::SilentOrbit.ProtocolBuffers.ProtocolParser.ReadUInt64(stream);
                        continue;
                    // Field 10 Varint
                    case 80:
                        instance.IntBase = (int)global::SilentOrbit.ProtocolBuffers.ProtocolParser.ReadUInt64(stream);
                        continue;
                    // Field 11 Varint
                    case 88:
                        instance.StaBase = (int)global::SilentOrbit.ProtocolBuffers.ProtocolParser.ReadUInt64(stream);
                        continue;
                    // Field 12 Varint
                    case 96:
                        instance.AgiBase = (int)global::SilentOrbit.ProtocolBuffers.ProtocolParser.ReadUInt64(stream);
                        continue;
                    // Field 13 Varint
                    case 104:
                        instance.DodgeBase = (int)global::SilentOrbit.ProtocolBuffers.ProtocolParser.ReadUInt64(stream);
                        continue;
                }

                var key = global::SilentOrbit.ProtocolBuffers.ProtocolParser.ReadKey((byte)keyByte, stream);

                // Reading field ID > 16 and unknown field ID/wire type combinations
                switch (key.Field)
                {
                    case 0:
                        throw new global::SilentOrbit.ProtocolBuffers.ProtocolBufferException("Invalid field id: 0, something went wrong in the stream");
                    default:
                        global::SilentOrbit.ProtocolBuffers.ProtocolParser.SkipKey(stream, key);
                        break;
                }
            }

            return instance;
        }
Пример #39
0
 /// <summary>Helper: put the buffer into a MemoryStream before deserializing</summary>
 public static APIMessage.SlotInventory Deserialize(byte[] buffer, APIMessage.SlotInventory instance)
 {
     using (var ms = new MemoryStream(buffer))
         Deserialize(ms, instance);
     return instance;
 }
Пример #40
0
 /// <summary>Helper: put the buffer into a MemoryStream before deserializing</summary>
 public static APIMessage.MasterCharacterClass Deserialize(byte[] buffer, APIMessage.MasterCharacterClass instance)
 {
     using (var ms = new MemoryStream(buffer))
         Deserialize(ms, instance);
     return instance;
 }
Пример #41
0
        public void UpdateSinglePlayerResult(int rank, int exGold)
        {
            object[] pars = { rank, exGold };
            APIMessage message = new APIMessage { Type = (int)enMessageType.EMT_CS_UpdateSinglePlayerResult, Parameters = pars };

            _ClientNet.SendMsg(message);
        }
Пример #42
0
        public bool SyncPlayerInfo(PlayerSyncInfo syncInfo)
        {
            object[] pars = { syncInfo };
            APIMessage message = new APIMessage { Type = (int)enMessageType.EMT_CS_SyncPlayerPos, Parameters = pars };

            _ClientNet.SendMsg(message);
            return true;
        }
Пример #43
0
 public void SendMsgToAllUser( APIMessage message)
 {
     if (message == null)
     {
         return;
     }
     foreach (var mem in _memberMap)
     {
         MatchMember Member = mem.Value;
         if (Member != null && Member.user != null)
         {
             Member.user.SendMsg(message);
         }
     }
 }
Пример #44
0
        public bool CompleteMatch(int nCompletePram = 0,int exGold = 0)
        {
            object[] pars = { nCompletePram, exGold };
            APIMessage message = new APIMessage { Type = (int)enMessageType.EMT_CS_CompleteMatch_22, Parameters = pars };

            _ClientNet.SendMsg(message);
            return true;
        }
Пример #45
0
 public bool CompleteMatchByMember(MatchMember matchMember)
 {
     if (matchMember == null || matchMember._user == null)
     {
         return false;
     }
     if (_nStartMatchTime <= 0)
     {
         return false;
     }
     matchMember._nCompleteTime = (int)(DelayEvent.GetCurUtcMSTime() - _nStartMatchTime);
     _CompleteMemberList.Add(matchMember);
     if (_CompleteMemberList.Count == 1)
     {
         int nCountdownTime = 10000;
         _CompleteTimeout = new MyTimeOut(nCountdownTime);
         object[] pars = { nCountdownTime };
         APIMessage message = new APIMessage { Type = (int)enMessageType.EMT_SC_CompleteStartCountdown, Parameters = pars };
         SendMsgToAllUser(message);
     }
     if (_CompleteMemberList.Count == _memberMap.Count)
     {
         CompleteMatch(true);
     }
     return true;
 }
Пример #46
0
        public void SendMsgToAllUserBesidesMe(User user, APIMessage message)
        {
            if (user == null || message == null)
            {
                return;
            }
            foreach (var mem in _memberMap)
            {
                MatchMember Member = mem.Value;
                if (Member.user.RoleID == user.RoleID)
                    continue;

                if (Member != null && Member.user != null)
                {
                    Member.user.SendMsg(message);
                }
            }
        }