关闭

关闭

封号提示

内容

首页 Syncfusion.ASP.NET SignalR.2013.pdf

Syncfusion.ASP.NET SignalR.2013.pdf

Syncfusion.ASP.NET SignalR.2013…

上传者: firmwu 2013-03-30 评分 0 0 0 0 0 0 暂无简介 简介 举报

简介:本文档为《Syncfusion.ASP.NET SignalR.2013pdf》,可适用于IT/计算机领域,主题内容包含ASPNETSignalRIncrediblysimplerealtimefeaturesforyourwebappsJoseMAguilarASP符等。

ASPNETSignalRIncrediblysimplerealtimefeaturesforyourwebappsJoseMAguilarASPNETSIGNALRINCREDIBLYSIMPLEREALTIMEFEATURESFORYOURWEBAPPSNoticeofLiabilityTheauthorandpublisherhavemadeeveryefforttoensuretheaccuracyoftheinformationhereinHowever,theinformationcontainedinthisbookissoldwithoutwarranty,eitherexpressorimpliedNeithertheauthorsandKrasisConsultingSL,noritsdealersordistributors,willbeheldliableforanydamagestobecausedeitherdirectlyorindirectlybytheinstructionscontainedinthisbook,orbythesoftwareorhardwareproductsdescribedhereinTrademarkNoticeRatherthanindicatingeveryoccurrenceofatrademarkednameassuch,thisbookusesthenamesonlyinaneditorialfashionandtothebenefitofthetrademarkownerwithnointentionofinfringementofthetrademarkKrasisConsulting,SLwwwcampusmvpnetALLRIGHTSRESERVEDNOPARTOFTHISBOOKMAYBEREPRODUCED,INANYFORMORBYANYMEANS,WITHOUTPERMISSIONINWRITINGFROMTHEPUBLISHERISBN:iiiContentsCONTENTSIIIINTRODUCTIONInternet,Asynchrony,Multiuser…wow!HTTP:YOUARETHECLIENT,YOUARETHEBOSSHttpoperationPolling:TheanswerPush:TheservertakestheinitiativeWebsocketsServerSentEvents(akaAPIEventSource)PushtodayLongpollingForeverframeTheworldneedsmorethanjustPushSIGNALRIntroducingSignalRWhatdoesSignalRofferInstallingSignalRTwolevelsofabstractionPERSISTENTCONNECTIONSIntroductionImplementationontheserversideEventsofaPersistentConnectionSendingmessagestoclientsAsynchronouseventprocessingConnectiongroupsClientsideimplementationInitiatingtheconnectionusingtheJavascriptclientSupportforcrossdomainconnectionsSendingmessagesReceivingmessagesOthereventsavailableattheclientTransportnegotiationCompleteexample:TrackingvisitorsImplementationontheclientsideHTMLmarkupivASPNETSignalRIncrediblysimplerealtimefeaturesforyourwebappsScripts(ScriptsTrackingjs)ImplementationontheserversidePersistentconnection(TrackerConnectioncs)Startupcode(Globalasaxcs)HUBSIntroductionServerimplementationRouteregistrationCreatingHubsReceivingmessagesSendingmessagestoclientsStatemaintenanceAccessinginformationabouttherequestcontextNotificationofconnectionsanddisconnectionsManaginggroupsClientimplementationJavaScriptclientsGeneratingtheproxyEstablishingtheconnectionSendingmessagestotheserverReceivingmessagesattheserverLoggingStatemaintenanceImplementingtheclientwithoutaproxyCompleteexample:SharedwhiteboardImplementationontheclientsideHTMLmarkupScripts(ScriptsDrawingBoardjs)ImplementationontheserversideHub(DrawingBoardcs)Startupcode(Globalasaxcs)PERSISTENTCONNECTIONSANDHUBSFROMOTHERPROCESSESAccessfromotherprocessesUsingpersistentconnectionsUsinghubsCompleteexample:progressbarImplementationontheclientsideHTMLmarkupStyles(StylesProgressBarcss)Scripts(ScriptsProgressBarjs)ImplementationontheserversideHubExpensiveprocess(HardProcessAspx)Startupcode(Globalasaxcs)ContentsvSIGNALROUTSIDETHEWEBSignalRclientsAccessingservicesfromnonwebclientsHostingservicesoutsideaspnet<coder>PremiumcoachedonlinetrainingforbusydevelopersMorethancannedvideosTutoredbytheoneswhoknowmostSpecifictrainingmethodologyDirectcontactwithourStudentsOfficeofourstudentsgiveusanAwwwcampusmvpnetGotnotimeandneedtolearnnewprogrammingskillsCHAPTERINTERNET,ASYNCHRONY,MULTIUSER…WOW!Anapplicationthatcombinesinternet,asynchrony,andmultipleuserscooperatingandinteractingatthesametimealwaysdeservesa“wow!”Atsomepoint,wehavealldoubtlesslybeenamazedbytheinteractivitywhichsomemodernwebsystemscanoffer,suchasFacebook,Twitter,Gmail,GoogleDocsormanyothers,wherewereceiveupdatesalmostinrealtime,withouthavingtoreloadthepageForinstance,whenweareeditingadocumentonlineusingGoogleDocsandanotheruseralsoaccessesit,wecanseethattheyhaveenteredandfollowthechangesthattheyaremakingonthedocumentEveninamoreeverydayscenariosuchasasimplewebchat,themessagesbeingtypedbyourfriendjustappearasifbymagicBothsystemsusethesametypeofsolution:asynchronousdatatransferbetweentheserverandtheclientsinrealtimeThroughoutthesepages,wewilllearnhowtoimplementimpressivefeaturesofthiskindusingSignalR,aframeworkwhichwillfacilitateourtasktothepointofmakingittrivialForthis,wewillfirstpresentabriefreviewoftheproblemsthatwefindwhendevelopingrealtimemultiuserapplicationsWewillquicklylookatHTTPoperationanditslimitationsforsupportingthistypeofsystems,andwewillintroducethePushconceptWewillalsodescribethestandardsthatarebeingpreparedbyWCandIETF,aswellastechniquesthatwecancurrentlyuseforimplementingPushonHTTPNext,wewillintroduceSignalR,describingitsmainfeaturesandthedifferentlevelsofabstractionwhichitallowsovertheunderlyingprotocolsWewillimplementdifferentexampleswhichwillhelpusunderstanditsbasesandgiveusinsightonhowwecanusethisframeworkinourprojectsIntroductionASPNETSignalRIncrediblysimplerealtimefeaturesforyourwebappsFinally,wewilldescribehowSignalRisindependentofWebenvironments,whichmeansthatitcanbehostedinanytypeofapplicationanditsrealtimeservicescanbeconsumedfrompracticallyanytypeofsystemCHAPTERHTTPOPERATIONHTTP(HyperTextTransferProtocol)isthelanguageinwhichtheclientandtheserverofawebapplicationspeaktoeachotherItwasinitiallydefinedin,andthesimplicityandversatilityofitsdesignare,toanextent,responsibleforthesuccessandexpansionoftheWebandtheInternetasawholeItsoperationisbasedonarequestresponseschemawhichisalwaysstartedbytheclientThisprocedureisoftenreferredtoasthePullmodel:Whenaclientneedstoaccessaresourcehostedbyaserver,itpurposelyinitiatesaconnectiontoitandrequeststhedesiredinformationusingthe“language”definedbytheHTTPprotocolTheserverprocessesthisrequest,returnstheresourcethatwasaskedfor(whichmaybethecontentsofanexistingfileortheresultofrunningaprocess)andtheconnectionisinstantlyclosedIftheclientneedstoobtainanewresource,theprocessstartsagainfromthebeginning:Aconnectiontotheserverisopened,therequestfortheresourceissent,theserverprocessesit,itreturnstheresultandthenclosestheconnectionThishappenseverytimeweaccessawebpage,imagesorotherresourcesthataredownloadedbythebrowser,togiveafewexamplesFigureHTTPcommunicationbetweenabrowserandawebserverSpecificationofHTTP:http:wwwworgProtocolsHTTPspechtmlHTTP:Youaretheclient,youarethebossASPNETSignalRIncrediblysimplerealtimefeaturesforyourwebappsAsyoucanguessbylookingattheimageabove,itisasynchronousprocess:Aftersendingtherequesttotheserver,theclientislefttowait,doingnothinguntiltheresponseisavailableAlthoughthisoperationisaclassicinwebsystems,theHTTPprotocolitselfcansupporttheneedsforasynchronyofmodernapplications,owingtothetechniquesgenerallyknownasAJAX(AsynchronousJavaScriptAndXML)UsingAJAXtechniques,theexchangeofinformationbetweentheclientandtheservercanbedonewithoutleavingthecurrentpageAtanygivenmoment,theclientmayinitiateaconnectiontotheserverusingJavaScript,requestaresourceandprocessit(forexample,updatingpartofthepage)Whatistrulyadvantageousandhascontributedtotheemergenceofverydynamicandinteractiveservices,suchasFacebookorGmail,isthattheseoperationsarecarriedoutasynchronously,thatis,theusermaykeepusingthesystemwhilethelattercommunicateswiththeserverinthebackgroundtosendorreceiveinformationFigureAjaxinawebpageThisoperatingschemacontinuestouseandabidebytheHTTPprotocolandtheclientdrivenrequestresponsemodelTheclientisalwaystheonetotaketheinitiative,decidingwhentoconnecttotheserverHowever,therearescenarioswhereHTTPisnotveryefficientWiththisprotocolitisnoteasytoimplementinstantmessagingapplicationsorchatrooms,collaborationtools,multiuseronlinegamesorrealtimeinformationservices,evenwhenusingasynchronyThereasonissimple:HTTPisnotorientedtorealtimeThereareotherprotocols,suchasthepopularIRC,whichareindeedfocusedonachievingswiftercommunicationinordertooffermoredynamicandinteractiveservicesthantheoneswecanobtainusingPullInthem,theservercantaketheinitiativeandsendinformationtotheclientatanytime,withoutwaitingforittorequestitexpresslyPOLLING:THEANSWERAswebdevelopers,whenwefaceascenariowhereweneedtheservertobetheonesendinginformationtotheclientonitsowninitiative,thefirstsolutionthatintuitivelyHTTP:Youaretheclient,youarethebosscomestoourmindsistousethetechniqueknownasPollingPollingbasicallyconsistsinmakingperiodicconnectionsfromtheclienttocheckwhetherthereisanyrelevantupdateattheserverFigurePollinginachatroomserviceThemainadvantagesofthissolutionare,first,itseasyimplementation,andsecond,itsuniversalapplication:itworksineverycase,withallbrowsersandwithallservers,sinceitdoesnothingmorethanusethestandardfeaturesofHTTPAnd,ofcourse,westillusethePullmodelHowever,sometimesthepriceofpollingistoohighConstantconnectionsanddisconnectionshaveahighcostintermsofbandwidthandprocessingatbothendsofcommunicationAndtheworstpartisthatthiscostincreasesproportionallytoourneedforfasterupdatesInanapplicationprovidingrealtimeupdates,itiseasytoimaginetheloadthataserverhastobearwhenithasthousandsofusersconnectedrequestingseveralupdatespersecondTherearetechniquestomitigatetheseproblemsinsofaraspossibleOneofthemistouseadaptiveperiodicity,sothattheintervalbetweenqueriesregularlyadaptstothecurrentsystemloadortotheprobabilityofnewupdatesItisquiteeasytoimplementandcansignificantlyimproveresourceconsumptioninsomescenariosThereisamoreconservativevariantofpolling,butitdegradesuserexperienceItisthetechniquecalledpiggybacking,whichconsistsinnotmakingdel

职业精品

精彩专题

上传我的资料

热门资料

资料评价:

/ 83
所需积分:1 立即下载

意见
反馈

返回
顶部

Q