Mono.Zeroconf – Diff between revs 1 and 2
?pathlinks?
Rev 1 | Rev 2 | |||
---|---|---|---|---|
Line 36... | Line 36... | |||
36 | { |
36 | { |
|
37 | private ushort port; |
37 | private ushort port; |
|
38 | private IAvahiEntryGroup entry_group; |
38 | private IAvahiEntryGroup entry_group; |
|
Line 39... | Line 39... | |||
39 | |
39 | |
|
40 | public event RegisterServiceEventHandler Response; |
40 | public event RegisterServiceEventHandler Response; |
|
- | 41 | |
||
- | 42 | private string originalName; |
||
- | 43 | private int retryNameModifier = 2; |
||
41 | |
44 | |
|
42 | public RegisterService () |
45 | public RegisterService () |
|
43 | { |
46 | { |
|
Line 44... | Line 47... | |||
44 | } |
47 | } |
|
Line 93... | Line 96... | |||
93 | private void OnEntryGroupStateChanged (EntryGroupState state, string error) |
96 | private void OnEntryGroupStateChanged (EntryGroupState state, string error) |
|
94 | { |
97 | { |
|
95 | switch (state) { |
98 | switch (state) { |
|
96 | case EntryGroupState.Collision: |
99 | case EntryGroupState.Collision: |
|
97 | if (!OnResponse (ErrorCode.Collision)) { |
100 | if (!OnResponse (ErrorCode.Collision)) { |
|
- | 101 | if (originalName == null) |
||
98 | throw new ApplicationException (); |
102 | originalName = Name; |
|
- | 103 | |
||
- | 104 | Name = originalName + " (" + retryNameModifier + ")"; |
||
- | 105 | retryNameModifier++; |
||
- | 106 | |
||
- | 107 | Console.WriteLine("ZeroConf had a name collision, trying: " + Name); |
||
- | 108 | |
||
- | 109 | Register(); |
||
99 | } |
110 | } |
|
100 | break; |
111 | break; |
|
101 | case EntryGroupState.Failure: |
112 | case EntryGroupState.Failure: |
|
102 | if (!OnResponse (ErrorCode.Failure)) { |
113 | if (!OnResponse (ErrorCode.Failure)) { |
|
103 | throw new ApplicationException (); |
114 | Console.WriteLine("Mono.ZeroConf failed to register name with AvahiDBus"); |
|
104 | } |
115 | } |
|
105 | break; |
116 | break; |
|
106 | case EntryGroupState.Established: |
117 | case EntryGroupState.Established: |
|
107 | OnResponse (ErrorCode.Ok); |
118 | OnResponse (ErrorCode.Ok); |
|
108 | break; |
119 | break; |